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.

3 comments
You shouldn't use wait() as your condition.
and connect is deprecated, use Connect.
https://docs.google.com/document/d/1ieZ8OzXPiXe3R7rs_xWmYZOnhQevlagN0ZWwoj_zKP4/edit