So I have made a script that is supposed to knock a character backwards when they get damaged. When facing the right direction, the character actually gets knocked backwards. When facing the opposite, it gets knocked forwards. How do I make it that the character always gets knocked backwards of themselves?
local ReplicatedStorage = game:GetService("ReplicatedStorage") p = ReplicatedStorage:FindFirstChild("YellowPoof") local tweeninfo = TweenInfo.new(0.85) local ts = game:GetService("TweenService") local goal = {} goal.Size = Vector3.new(11, 11, 11) goal.Transparency = 1 db = true local Health = script.Parent.Humanoid.Health function onHurt() if db == true and script.Parent.Humanoid.Health < Health then db = false local humanoid = script.Parent.Humanoid local p2 = p:Clone() local tween = ts:Create(p2, tweeninfo, goal) p2.Parent = humanoid.Parent.LowerTorso p2.Position = humanoid.Parent.LowerTorso.Position tween:Play() local animation = humanoid:LoadAnimation(script.Animation) animation:Play() humanoid.WalkSpeed = 0 -- Line I need help with!! script.Parent.HumanoidRootPart.Position = Vector3.new(script.Parent.HumanoidRootPart.Position.X,script.Parent.HumanoidRootPart.Position.Y,script.Parent.HumanoidRootPart.Position.Z-5) wait(1.85) humanoid.WalkSpeed = 19.5 db = true end end script.Parent.Humanoid.HealthChanged:Connect(onHurt)