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

Im trying to make a hoverboard but when I turn it kinda does a full circle?

Thank you for reading

local Part = game.Workspace.Part
local holdingUKey = false
local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(inputObject) 

	if(inputObject.KeyCode==Enum.KeyCode.E)then

		holdingUKey = true
		while holdingUKey do
			Part.CFrame = CFrame.Angles(0,1,0)*Part.CFrame
			wait(0.001)
		end

	end
end)
UIS.InputEnded:Connect(function(inputObject)
	if(inputObject.KeyCode==Enum.KeyCode.E)then
		holdingUKey = false
	end
end)

1 answer

You are attempting to rotate by one radian, not one degree. This is because CFrame.Angles() takes its arguments in radians.

Instead do this:

Part.CFrame = CFrame.Angles(0,math.rad(1),0) * Part.CFrame

Words of advice, your title should be more concise and your question shouldn't just be code without elaboration.

3 comments

0

If you don't know, a circle is made up of three-sixty degrees which is the same as two pi radians.

0

It is still doing it it is rotating in a full circle I just want it to turn like when you rotate in roblox studio

0

The average reaction time is 250 ms while your script waits for only 1 ms. By the time the player stops pressing the key, he will have rotated atleast 250 degrees. Try waiting for longer maybe one tenth of a second, so you move ten degrees in a second.

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