I'm experimenting with loops inside of loops and this is my first attempt, but when I click, Studio will always crash and I don't know why. Here is script:
loop = 1 while true do while loop < 8 do wait(1) script.Parent.Parent.HingeConstraint.TargetAngle = script.Parent.Parent.HingeConstraint.TargetAngle - 6 loop = math.random(1,10) end local CD = script.Parent -- Clickdetector CD.MouseClick:connect(function(click) loop = math.random(1,7) end) end
An event will be activated when it's... activated.
You don't need a loop for that, also you forgot a wait() wich can also break your script.
loop = 1 local CD = script.Parent -- Clickdetector while true do wait() while loop < 8 do wait(1) script.Parent.Parent.HingeConstraint.TargetAngle = script.Parent.Parent.HingeConstraint.TargetAngle - 6 loop = math.random(1,10) end end CD.MouseClick:connect(function(click) loop = math.random(1,7) end)
Also, why do you have two loops inside each other??