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

CFrame.Angles is way to drastic?

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

0

You shouldn't use wait() as your condition.

0

and connect is deprecated, use Connect.

1 answer

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)

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