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

Attempt to compare two userdata values pls help?

Asked by 5 years ago
local plr = game.Players.LocalPlayer

local PlayerGui = plr:WaitForChild('PlayerGui')
-
local ScreenGui = PlayerGui:WaitForChild('1stLoadingScreen') --ScreenGui

local StartButton = ScreenGui.Frame.PlayLabel -- A TextLabel





spawn(function()

StartButton:GetPropertyChangedSignal('Size'):Connect(function()

if StartButton.Size >= UDim2.new(0.1,0,0.1,0) then -- THIS IS WHERE THE PROblEM OCCURS





print('it is past that ')

end

end)

end)





spawn(function()

while wait(.1) do

StartButton.Size = StartButton.Size + UDim2.new(.01,0,.01,0)



end

end)
0
Might I suggest comparing AbsoluteSize coordinates. You can not compare an entire UDim2 to another UDim2, you must treat it as X and Y coordinates. UDim2.new(XScale, XOffset, YScale, YOffset) M39a9am3R 3210 — 5y
0
ud2.X.Scale, ud2.X.Offset, ect ect User#24403 69 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

StartButton.Size is a userdata value indeed, you cannot compare a UDim2 to it because it is not a number or integer, in which you can only compare those, same goes for stuff such as Vector3 and CFrame

A easy solution to this however, is to add

 if StartButton.Size.X.Scale >= 0.1 and StartButton.Size.Y.Scale >= 0.1 then
 --DO THIS

Due to UDim2 not being a data TYPE of a, "Number," it does not know what to compare to, but if you index down to, "X," or, "Y," it will automatically see X or Y as a number, and not a UDim2

0
Obviously, if you need the conditions for the if statement changed, use the same format with the X and Y axis, i.e, "or," and not, "and," Dev_Unreal 136 — 5y
Ad

Answer this question