Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you make the character point to a certain direction with userinputservice?

1 answer

✓ Accepted answer

Well, it's actually quite simple, and you don't need BodyGyro at all. Just change the CFrame of the Character's HumanoidRootPart to the same position, and change the angle to The Camera's CFrame position. Here's an example with what you want to do.

Note: I changed the button you press from S to F so I could make sure it worked. S makes you walk backwards if your game isn't 2D :P. If you want to change it back, change Enum.KeyCode.F at line 5 to Enum.KeyCode.S.

local player = game:GetService("Players").LocalPlayer
local usi = game:GetService("UserInputService")

usi.InputBegan:connect(function(obj)
	if obj.KeyCode == Enum.KeyCode.F then
		local character = workspace:FindFirstChild(player.Name)
		local camera = workspace.CurrentCamera
		character.HumanoidRootPart.CFrame = CFrame.new(character.HumanoidRootPart.CFrame.p, camera.CFrame.p * -1)
	end
end)

1 comment

0

thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.