So, I am trying to make this script randomise a motor6d start position, then go either down or up and then just keep going down and up. It works fine until the repeat. It goes to StartPosition and moves to DesiredPosition and then go the other way but then it stop and won't keep going up/down.
I tried this at first:
local tilt = script.Parent.Startposition.Value
function OnClick(Player)
script.Parent.Startposition.Value = math.random(-15,15)/10
script.Parent.Desiredposition.Value = math.random(0,4)
wait (0.5)
script.Parent.Tilt.CurrentAngle = script.Parent.Startposition.Value
wait (0.05)
script.Parent.Tilt.DesiredAngle = script.Parent.Startposition.Value
wait (0.05)
if script.Parent.Desiredposition.Value >= 3 then
script.Parent.Tilt.DesiredAngle = 1.5
script.Parent.Direction.Value = 1.5
else
script.Parent.Tilt.DesiredAngle = -1.5
script.Parent.Direction.Value = -1.5
end
repeat wait(0.1) until script.Parent.Tilt.CurrentAngle == script.Parent.Direction.Value
print ("weee")
--- I think this below is what won't work
repeat
if script.Parent.Direction.Value == 1.5 then
script.Parent.Tilt.DesiredAngle = -1.5
else
script.Parent.Tilt.DesiredAngle = 1.5
end
repeat wait(0.1) until script.Parent.Tilt.CurrentAngle == script.Parent.Tilt.DesiredAngle
until
script.Parent.On.Value == false
end
game.Workspace.TES2.ClickDetector.MouseClick:connect(OnClick)
Did not output any errors and still did not work so I tried changing the repeat to another thing but still did not work better.
print ("weee")
repeat
if script.Parent.Tilt.DesiredAngle == 1.5 then
script.Parent.Tilt.DesiredAngle = -1.5
else
script.Parent.Tilt.DesiredAngle = 1.5
end
repeat
wait(0.1)
until
script.Parent.Tilt.CurrentAngle == script.Parent.Tilt.DesiredAngle
until
script.Parent.On.Value == false
end
All help appreciated.
[ EDIT BELOW ] I tried switching to this too. Still no errors and still won't work.
print ("weee")
repeat
if script.Parent.Tilt.DesiredAngle == 1.5 then
script.Parent.Tilt.DesiredAngle = -1.5
else
script.Parent.Tilt.DesiredAngle = 1.5
repeat wait(0.1) until script.Parent.Tilt.CurrentAngle == script.Parent.Tilt.DesiredAngle
end
until script.Parent.On.Value == false
end
