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

It says that I can't compare the GUI Sizes?

Here's the line that It says attempt to compare two userdata values

if .Parent.Bars.Thirst.Amount.Size >= UDim2.new(0,0,0,0) then
local KillPlayer = game.Players.LocalPlayer.Character.Humanoid
Humanoid.Health = -1
end

4 comments

0

You have to be very specific; there's two values to GUIs (such as Frames, TxtBttns, TxtLbls, etc.), which are the Y and X values, which serves two different purposes. Y works up-and-down, and X works left-to-right. They both come with values...

0

Known as the Offset and Scale values; Offset is a property to have the GUI support all devices, while Scale works in pixels, and will not support all devices. With these values, you can compare them to a specific number, but to note, you can't change them: you have to do it via the UDim2 function (in game), or going into studio to change them.

0

So can you fix it for me?

0

Well, all you need to do is, for how your script is, set up your script like this: if Size.Y.Scale >= 0 then, but if you're trying to compare a different value, then you'll have to have it be compared by the X or Y values, depending on what you're trying to do.

1 answer

Instead of comparing GUI sizes, I'm pretty sure you have a IntValue or NumberValue that stores how much thirst there is. Or if you don't already add a IntValue into Amount and do this;

local TA = script.Parent:WaitForChild('Bars').Thirst.Amount.IntValue --ThirstAmount

if TA.Value <= 0 then
	local KillPlayer = game.Players.LocalPlayer.Character.Humanoid
	KillPlayer.Health = 0 -- 0 Health kills player
end

If this helped then please accept answer ;)

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