Players.milesm2k.PlayerGui.Penalty.Diagram.Execute.StopCursors:8: bad argument #2 to '?' (UDim expected, got number)
It says that line 8 is the problem, but I'm not sure why it doesn't see Cursor1.Position.X as a number.
function Click() if script.Parent.Parent.Parent.Cursor1InPlay.Value == true then script.Parent.Parent.Parent.Cursor1InPlay.Value = false script.Parent.Parent.Parent.Cursor2InPlay.Value = true elseif script.Parent.Parent.Parent.Cursor2InPlay.Value == true then script.Parent.Parent.Parent.Cursor2InPlay.Value = false local Cursor1Pos = script.Parent.Parent.Cursor1.Position.X local x = 24.125 - (0.100520833 * (Cursor1Pos-7)) workspace.PKLauncher.Orientation = Vector3.new(0,x,90) end end script.Parent.MouseButton1Click:connect(Click)
The issue in line 8 is that Cursor.Position.X and Cursor.Position.Y are UDim values, not integers.
So how can you actually get the integer value of the mouse's X position?
Depending on what you are doing, you should either supply Cursor1Pos.Offset
or Cursor1Pos.Scale
A UDim's Offset and Scale are both integer values, however the Offset is the X position's value in pixels, and the Scale is the X position's value relative to your screen resolution.
I am assuming you want to use the Offset since the Offset is based on pixels, so here is a quick fix for you:
function Click() if script.Parent.Parent.Parent.Cursor1InPlay.Value == true then script.Parent.Parent.Parent.Cursor1InPlay.Value = false script.Parent.Parent.Parent.Cursor2InPlay.Value = true elseif script.Parent.Parent.Parent.Cursor2InPlay.Value == true then script.Parent.Parent.Parent.Cursor2InPlay.Value = false local Cursor1Pos = script.Parent.Parent.Cursor1.Position.X local x = 24.125 - (0.100520833 * (Cursor1Pos.Offset - 7)) workspace.PKLauncher.Orientation = Vector3.new(0,x,90) end end script.Parent.MouseButton1Click:connect(Click)
Cursor1Pos - 7
will cause an error because no operator overload allows you to subtract a UDim with an integer. You can only subtract UDims with other UDims.
Cursor1Pos.Offset - 7
will not fail because you are subtracting two integers together, which is perfectly legal in programming.
I hope this helped you.