I Am Working On A Game Where When Players Knock Into Each Other, They Are Pushed Back In The Opposite Direction The Torso Is Facing. I Have Written Some Code To Do This, But It Is Not Working As Intended,
local player = game.Players.LocalPlayer local Body = script.Parent:WaitForChild("Torso") local Humanoid = script.Parent:WaitForChild("Humanoid") Humanoid.Touched:Connect(function(HitBody) if HitBody.Name == "Torso" then print("Launch") Body.Velocity = Vector3.new(Body.Position.X / Body.Position.X * HitBody.Size.X * -1, 0, Body.Position.Z / Body.Position.Z * HitBody.Size.Z * -1) end end)
You should create a new BodyVelocity instance. After you do that, do:
local bodyVel = Instance.new("BodyVelocity") bodyVel.Velocity = character.CFrame.LookVector bodyVel.MaxForce = Vector3.new() * math.huge bodyVel.Parent = character.PrimaryPart --note: intentional errors in given code