local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
-- Create a "Touch" event for the character's HumanoidRootPart
humanoid.RootPart.Touched:Connect(function(hit)
-- Check if the character is colliding with another player
local targetPlayer = game.Players:GetPlayerFromCharacter(hit.Parent)
if targetPlayer then
-- Apply a force to the other player's character to push it
local force = (hit.Position - character.HumanoidRootPart.Position).unit * 50
hit.Parent:FindFirstChildOfClass("Humanoid"):AddForce(force)
end
end)
4 comments