So basically, I am trying to make a treasure box which flips open if you click on it. Why is it not working? The lid rotates around a hinge on the end of the box.
Here are the error messages in output I am receiving:
20:36:48.733 - Workspace.Pandora.Spin:14: 'end' expected (to close 'function' at line 1) near '' 20:36:48.734 - ClickDetector is not a valid member of Model
Other info:
First I tried storing it in server script storage, then in the box's model itself.
function onClicked(PlayerWhoClicked)
local lid = workspace:WaitForChild("Lid")
local hinge = workspace:WaitForChild("Hinge")
local hingePos = hinge.Position
for i = 1,180 do
lid.CFrame = CFrame.new(hingePos)* CFrame.Angles(0,math.rad(i),0) * CFrame.new (3,0,0)
wait()
end
workspace.Pandora.ClickDetector.MouseClick:connect(onClicked)

1 comment
Thanks dude! How would I fix the instance Pandora?