I am basicly trying to make a script that randomises a motor6d's start position then goes either up and down and after that it should keep going up and down until a "On" boolvalue gets turned to false.
I get the error Workspace.BLR2.Script:26:attempt to index field 'DesiredAngle' (a number value) and don't get how to fix it.
All help is greatly appreciated! Thank you.
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")
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.Value
until
script.Parent.On.Value == false
end
game.Workspace.TES2.ClickDetector.MouseClick:connect(OnClick)

1 comment
Thank you. Error gone. Now the problem is just that the last function won't work at all. Another question for that though.