Player can go out of bounds on a gui

I want to make an out of bounds zone on a gui

but when it goes out of bounds nothing has happened. Here is the script: repeat
if player.Position.X == UDim2.new({-0.092, 0}) or UDim2.new({1, 0}) then
GameOver()
end
if player.Position.Y == UDim2.new({-0.095, 0}) or UDim2.new({0.998, 0}) then
GameOver()
end
until script.Parent.Parent.Visible == false

there is only one result but it is kind of confusing

Don’t use loops to check

This is what events are for.

Secondly, what is this variable “player”

Thirdly,

put code in code blocks
use ```
1 Like

the player is the thing you control on the gui

1 Like

okay well make an event when the “player” moves position, then do the check in the event.

Secondly, Udim2.new() takes 2-4 numbers as parameters, not tables.

Thirdly, if you want to see if it’s out of bounds you’d probably want to do >=/<= instead of ==

repeat
if player.Position.X.Scale <= -0.092 or player.Position.X.Scale >= 1 then
	GameOver()
end
if player.Position.Y.Scale <= -0.095 or player.Position.Y.Scale >= 0.998 then
	GameOver()
end
until script.Parent.Parent.Visible == false
1 Like

this works, thank you.I understand now :cowboy_hat_face:

You’re also missing a “repeat” statement at the top of the code.

That doesn’t really matter… I’m sure they have a high enough IQ to notice that themselves. Don’t you think they would’ve said something by now?

They might’ve not noticed that subtle change, since you didn’t mention it.

sorry I haven’t replied in a while and I did put a repeat lol