Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I fix this error? Attempt to index field 'DesiredAngle' (a number value)

Asked by 6 years ago

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 answer

Log in to vote
0
Answered by
Avigant 2374 Moderation Voter Community Moderator
6 years ago

repeat wait(0.1) until script.Parent.Tilt.CurrentAngle == script.Parent.Tilt.DesiredAngle.Value

You are attempting to index Motor6D.DesiredAngle as if it's a table or userdata, but it's a number. Remove the .Value part at the end.

Also, RBXScriptSignal:Connect() with a capital C, as the lowercase version you're using is deprecated.

0
Thank you. Error gone. Now the problem is just that the last function won't work at all. Another question for that though. tim458458 29 — 6y
Ad

Answer this question