game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0 player = game.Players.LocalPlayer hum = player.Character --[[function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.W then hum.Torso.Position = hum.Torso.Position + Vector3.new(0,0,5) end end game:GetService("UserInputService").InputBegan:connect(onKeyPress)--]] function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.W then hum.Torso.CFrame = hum.Torso.CFrame + CFrame.new(0,0,5) end end game:GetService("UserInputService").InputBegan:connect(onKeyPress)
the commented part is the vector3 one that didnt have any errors, but detached me torso from the character. i wanted to use CFrame because i want the rest of the player to move with the body.
You can't add CFrames, only multiply them.
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0 player = game.Players.LocalPlayer hum = player.Character --[[function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.W then hum.Torso.Position = hum.Torso.Position + Vector3.new(0,0,5) end end game:GetService("UserInputService").InputBegan:connect(onKeyPress)--]] function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.W then hum.Torso.CFrame = hum.Torso.CFrame * CFrame.new(0,0,5) -- Can't Add CFrames only multiply them. end end game:GetService("UserInputService").InputBegan:connect(onKeyPress)