Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Damo999 182
8 years ago

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

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
8 years ago

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)




0
Ah okay I understand now thank you. Damo999 182 — 8y
Ad

Answer this question