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

Why does the Angle reset?

local run = game:GetService("RunService").RenderStepped


local keyheldq = false
local keyhelde = false

function onKeyPressQ(inputObject, gameProcessed)
	if inputObject.KeyCode == Enum.KeyCode.Q then
		keyheldq = true
		while keyheldq do
			
		torsorot = 0
		local rot = 0
		
		while torsorot < 100 do
			
			torso.CFrame = CFrame.new(torso.Position) * CFrame.Angles(0, rot, 0)
			
			rot = rot + .01
			
			print(rot)
			run:wait()
		end
				
			
			wait()
		end
	end
end


function onKeyReleaseQ(inputObject, gameProcessed)
	if inputObject.KeyCode == Enum.KeyCode.Q then
	print("Stopped holding the Q!")
	torsorot = 100
	torso.CFrame = CFrame.new(torso.Position)
		keyheldq = false
	end
end

game:GetService("UserInputService").InputBegan:connect(onKeyPressQ)
game:GetService("UserInputService").InputEnded:connect(onKeyReleaseQ)

When the key Q is released, it doesn't stay at the Angle, it resets the angle to 0 again, and it doesn't stay,

I'm trying to make a character customization menu.

This is for character rotation as you might noticed.

1 comment

0

Try making the rotation variable go through the entire script. This will mean you won't have to redefine it every time you want to make a change etc.

1 answer

✓ Accepted answer

Line 36

torso.CFrame = CFrame.new(torso.Position). You just reset the angle. Unless the thing is going to move, don't even bother setting the Position with it.


On a side note, if you're planning on making it rotate the other direction, you might want to take rot out of that loop so that you can keep it between events.

5 comments

0

How did you get that line in between paragraphs? I've been trying to figure out how to do it for a while.

0

--- or *** with a line of clearance on either side.

0

It's only worked with _________ for me...

0

Thanks!

0

Thanks!

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