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

This script won't work, can you please help me?

I'm trying to code that when you run out of water in the GUI I made, the hose that sprays water will be named to something else so it can't spray any longer.

while true do
wait(1)
if script.Parent.Size.Y >=  (UDim.new(0, 0)) then
game.Players.LocalPlayer.Character.Chest.hose.name = "broken"
end
end

Error: 17:07:40.871 - Players.Player1.PlayerGui.ScreenGui.water.Script:3: attempt to compare two userdata values

1 answer

✓ Accepted answer

UDim2 does not have relational operators. If you want to check if the size is less than something, refer to the AbsoluteSize, which is measured in pixels, or if you want to have it still in percent form, divide the AbsoluteSize by workspace.CurrentCamera.ViewportSize to get the relative size to the screen.

4 comments

0

Thank you 1waffle1, but now I get this error after doing that. 18:27:04.850 - Players.Player1.PlayerGui.ScreenGui.water.Script:3: attempt to compare userdata with number

0

I don't know what you did so I can't fix what you did wrong.

0

while true do wait(1) if script.Parent.AbsoluteSize.Y >= (UDim.new(0, 0)) then game.Players.LocalPlayer.Character.Chest.hose.Name = "broken" end end

0

I said UDim2 does not have relational operators. You can't do that. You're trying to compare a number to something that isn't a number.

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