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

CFrame.Angles is way to drastic?

Asked by 5 years ago

So im trying to make a box open by it being slow at first but speeding up each time it reaches the limit and then exploding. However the Orientation movements are WAY to drastic.

Here is my code!

local times = 1
local factor = 1
local rotation = 0

while wait(0.3) do
    if times == 6 then
        break
    end
    for i,x in pairs(script.Parent:GetChildren()) do
        if x:IsA("BasePart") then
            print(x.Orientation.X-factor)
            x.CFrame = x.CFrame * CFrame.Angles(x.Orientation.X-factor,0,0)
        end
    end
    rotation = rotation - factor
end

script.Parent.Union.Changed:connect(function()
    if rotation == -40 then
        times = times + 1
        factor = -times
    elseif rotation == 40 then
        times = times + 1
        factor = times
    end
end)

I have no idea what I am doing wrong.

0
You shouldn't use wait() as your condition. User#19524 175 — 5y
0
and connect is deprecated, use Connect. User#19524 175 — 5y

1 answer

Log in to vote
1
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
5 years ago

Because you're inputting degrees when CFrame.Angles takes radians. You need to convert it to radians by using math.rad.

x.CFrame = x.CFrame * CFrame.Angles(math.rad(x.Orientation.X-factor), 0, 0)
Ad

Answer this question