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

How do I make math.rad transition smooth using for loops?

The above question is a bit confusing but I was wondering how would i go about using math.rad(90) in a for loop for an animation I started the script I tried to get it to work but instead of it going smoothly into the animation it skips straight to 90 degrees

RA = game.Workspace.Damo999["Right Arm"]
RS = game.Workspace.Damo999.Torso["Right Shoulder"]
mouse = game.Players.Damo999:GetMouse()


mouse.KeyDown:connect(function(key)
	if key == "r" then
		for i = 1,1 do
			RS.C0 = RS.C0*CFrame.Angles(0,0,math.rad(90))
			wait()
	end
	elseif key == "t" then
		RS.C0 = RS.C0*CFrame.Angles(math.rad(45),0,0)
	end
	end)



it just won't transition smoothly but skips to 90 degrees i'm not sure how to fix his someone told me to use tick() but i don't fully understand so please help thank you.

1 answer

✓ Accepted answer

Your for loop on line 8 has one iteration and is moving 90 degrees. You need to break up the for loop into increments, as well as how much you're moving it.

local RA = workspace.Damo999["Right Arm"]
local RS = workspace.Damo999.Torso["Right Shoulder"]
local mouse = game.Players.Damo999:GetMouse()


mouse.KeyDown:connect(function(key)
	if key == "r" then
		for i = 1,90  do --iterate 90 times, move 1 degree in each increment
			RS.C0 = RS.C0*CFrame.Angles(0,0,math.rad(1))
			wait()
		end
	elseif key == "t" then
		RS.C0 = RS.C0*CFrame.Angles(math.rad(45),0,0)
	end
end)




1 comment

0

Ah okay I understand now thank you.

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