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

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

Asked by 8 years ago

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

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
8 years ago

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.

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 crazy1755 5 — 8y
0
I don't know what you did so I can't fix what you did wrong. 1waffle1 2908 — 8y
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 crazy1755 5 — 8y
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. 1waffle1 2908 — 8y
Ad

Answer this question