Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

1 comment

0

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

This discussion is preserved as it was. New answers, comments, and votes are closed.