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

Is there a way to remove player turn time?

Is there a way to remove the time it takes for a player to turn around? For my purposes I need for them to instantly turn around. I've thought about using BodyGyros, but I've never used that before so I'm not entirely sure how to go about it.

1 answer

✓ Accepted answer

You could set the CFrame of the player's HumanoidRootPart on a key press. An example implementation could be the following. Note that this does not include diagonal angles, but it should be fairly easy to implement.

-- assuming this is a localscript inside the player's character
local RootPart = script.Parent.HumanoidRootPart
game:GetService("UserInputService").InputBegan:connect(function(Input, Event)
	if not game:GetService("UserInputService"):GetFocusedTextBox() then
		local Angles = CFrame.new(Vector3.new(), workspace.CurrentCamera.CFrame.lookVector * Vector3.new(1, 0, 1))
		if Input.KeyCode == Enum.KeyCode.W then
			RootPart.CFrame = CFrame.new(RootPart.CFrame.p) * Angles
		elseif Input.KeyCode == Enum.KeyCode.S then
			RootPart.CFrame = CFrame.new(RootPart.CFrame.p) * Angles * CFrame.Angles(0, math.pi, 0)
		elseif Input.KeyCode == Enum.KeyCode.A then
			RootPart.CFrame = CFrame.new(RootPart.CFrame.p) * Angles * CFrame.Angles(0, math.pi / 2, 0)
		elseif Input.KeyCode == Enum.KeyCode.D then
			RootPart.CFrame = CFrame.new(RootPart.CFrame.p) * Angles * CFrame.Angles(0, -math.pi / 2, 0)
		end
	end
end)

1 comment

0

Wow works like a charm! Thank you so much!

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