I want the character to look where the mouse is pointing for a few seconds, but when I try it, it just makes the player fall down. Like this
Here is the code that I'm using:
cooldown36 = 0 script.Parent.Pound36.OnServerEvent:Connect(function(Player, mousehit) if Player.Stats.Stamina.Value >= 350 and Player.NonStats.Stunned.Value == false and Player.Character.Humanoid.Health ~= 0 and Player.NonStats.Attacking2.Value == false and Player.Stats.Blade.Value >= 40 and cooldown36 == 0 then cooldown36 = 1 Player.NonStats.Attacking.Value = true Player.NonStats.Attacking2.Value = true Player.Stats.Stamina.Value = Player.Stats.Stamina.Value - 350 local Fire = Player.Character.Humanoid:LoadAnimation(script.Parent.Fire) Player.Character.Humanoid.WalkSpeed = 0 Fire:Play() local Torso = Player.Character.LowerTorso Torso.CFrame = CFrame.new(Torso.Position, Vector3.new(mousehit.p.X, 0, mousehit.p.Z)) wait(1) Player.NonStats.Attacking2.Value = false if Player.NonStats.Sprint.Value == true then Player.Character.Humanoid.WalkSpeed = 30 end if Player.NonStats.Sprint.Value == false then Player.Character.Humanoid.WalkSpeed = 16 end Player.NonStats.Attacking2.Value = false wait(20) cooldown36 = 0 end end)
Thanks for reading!
There's an easy way to make the player face where the mouse is pointing for a few seconds.
If everything is working, but the character is falling, then it is because the HumanoidRootPart of the Character isn't Anchored. Make sure you do Player.Character.HumanoidRootPart.Anchored = true
, if everything isn't working, I made my own code that MIGHT work.
If the only problem is the character falling, then simply anchor the HumanoidRootPart, otherwise:
Use the following code to get the direction:
local direction = (mousehit.p - Player.Character.HumanoidRootPart.Position) * Vector3.new(1, 1, 1); direction = CFrame.new(Player.Character.HumanoidRootPart.Position, Player.Character.HumanoidRootPart.Position + direction)
And use the following code to make the player face that direction:
Player.Character.HumanoidRootPart.CFrame = direction
Please let me know what works and what doesn't, leave a comment if something's wrong or if you're confused. Be sure to accept my answer if I solved your question and help a guy out :3 Good luck