How do I make a character move 20 studs the direction the Torso is facing?
This seems like a basic question to me. I've tried multiple this.
I've tried,
01 | local tool = script.Parent |
02 | local plr = game.Players.LocalPlayer |
03 | local char = plr.Character or plr.CharacterAdded:wait() |
04 | local Torso = char:WaitForChild( "Torso" ) |
05 | local mouse = plr:GetMouse() |
06 | tool.Equipped:connect( function () |
07 | tool.Activated:connect( function () |
08 | Torso.CFrame = (Torso.CFrame*CFrame.new(Torso.CFrame.lookVector* 20 )) |
In this one I tried to use math. The player does move, just not always in the right direction.
I've also tried,
1 | local tool = script.Parent |
2 | local plr = game.Players.LocalPlayer |
3 | local char = plr.Character or plr.CharacterAdded:wait() |
4 | local Torso = char:WaitForChild( "Torso" ) |
5 | tool.Equipped:connect( function () |
6 | tool.Activated:connect( function () |
7 | Torso.CFrame = Torso.CFrame:toWorldSpace(CFrame.new(Torso.CFrame.lookVector)) |
In this one I tried using :toWorldSpace()
and this had almost the same result as the other attempt.
There were no errors. The only problem is the way it moves the player. Sometimes the player can get moved backwards and other times the player moves sideways. It only seems to work if the player is facing a single direction.
Any help would be awesome.
Thank you.