Initially, my script looked like:
function onClicked(PlayerWhoClicked)
script.Parent.Lid.CFrame = script.Parent.Lid.CFrame * CFrame.Angles(math.rad(130), 0,0)
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
The box "opened", however, it only rotated along it's own axis. I want the lid to rotate relative to a hinge connecting to the box.
And one more problem with that script, was that it rotated stud by stud every time you clicked it, and never stops. I want it to flip open to a certain point with one click, and thats it.
So I wrote this new script:
local hinge = workspace:WaitForChild("Hinge")
local lid = script.Parent:WaitForChild("Lid")
hingePos = hinge.Position
function onClicked(PlayerWhoClicked)
for i = 1,180 do
lid.CFrame = CFrame.new(hingePos)* CFrame.Angles(math.rad(i),0,0)* CFrame.new(14.195,0,0)
wait()
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
I click, and nothing happens. What went wrong?
