How can I make a Players GUI change depending on the Zone they just entered

Hello! I am wondering, how can I make it when a player walks into a Zone, it will change their GUI. For example, let’s say they have Money and Coins for a specific area, and they go into a new Zone, their Money and Coins GUI would change into another currency, for example, Snow Money, and Snow Coins. How can I achieve this? I know ZonePlus is a great alternative, but I am not sure how it really works.

Any help will be appreciated! :grinning_face_with_smiling_eyes:

all you need to know for zone plus is

local Zone = require(where ever the zone module is)

local new_zone = Zone.new(instance)

zone.playerEntered:Connect(function(plr)

end)

zone.playerExited:Connect(function(plr)

end)

Yea well, I knew that for sure. Doesn’t really tell me exactly what to do?

It should,

zone.new() makes a new zone out of a part that you give it.

playerEntered detects when a player enters and you can do an action on that player

Yes, I know that. But each area has a different GUI? So how would that work exactly?

you would need to make 2 separate zones for each area. and detect when a player enters each of them.

if you wanted to hide the UI from the previous area u would need to handle that too with the “playerExited” signal

What do you mean by you would need to make 2 separate zones for each area. and detect when a player enters each of them? Do you mean in the script?

yeah so like this

local area1 = Zone.new(part_to_represent_area_1)
local area2 = Zone.new(part_to_represent_area_2)

btw incase if you didn’t know, if I had a part that looks like this

everything within the part would be considered “In that zone”

Alright, so I think I am understanding this more. Can’t I make a folder named “Regions” In ReplicatedStorage and I assume use that as the part? Well ofcourse parts being inside that folder.

Yes, you could group a bunch of parts in a folder and that could be used as the zone.

Like this?

local Zone = require(script.Change)
local Regions = game.ReplicatedStorage.Regions

local Zone1 = Zone.new(Regions.Zone1)
local Zone2 = Zone.new(Regions.Zone2)

Zone1.playerEntered:Connect(function(plr)
	
end)

Zone1.playerExited:Connect(function(plr)
	
end)

And if so, what do I put in the playerEntered?

You have to check when a player entered both zones seperately

Zone1.playerEntered:Connect(function(plr)
	
end)

Zone1.playerExited:Connect(function(plr)
	
end)

Zone2.playerEntered:Connect(function(plr)
	
end)

Zone2.playerExited:Connect(function(plr)
	
end)

As for what to put in them, that’s up to you. If you tryna hide/show the ui object then you would wanna put the “show” behavior in player entered and the “hide” behavior in the exited signal.

1 Like

So it doesn’t seem to want to change?

local Zone = require(script.Change)
local Regions = game.ReplicatedStorage.Regions2

local player = game:GetService("Players").LocalPlayer
MainPC = player:WaitForChild("PlayerGui"):WaitForChild("Main PC")

local Zone1 = Zone.new(Regions.Zone1.Part)
local Zone2 = Zone.new(Regions.Zone2.Part)

Zone1.playerEntered:Connect(function(plr)
	MainPC.RightCoins["SnowCoin Leaderstat"].Visible = true
	MainPC.RightMoney["SnowCash Leaderstat"].Visible = true
	
	MainPC.RightCoins["Coin Leaderstat"].Visible = false
	MainPC.RightMoney["Money Leaderstat"].Visible = false
end)

Zone1.playerExited:Connect(function(plr)
	MainPC.RightCoins["Coin Leaderstat"].Visible = true
	MainPC.RightMoney["Money Leaderstat"].Visible = true
	
	MainPC.RightCoins["SnowCoin Leaderstat"].Visible = false
	MainPC.RightMoney["SnowCash Leaderstat"].Visible = false
end)

They’re also no errors.

so the exited function I would make that only handle making the snow thing invisible and not making the other stuff visible.

If you think about it, if you leave an area to some random place, you wouldn’t want any ui showing from the other areas.

Yea, but that doesn’t really solve my issue with it not showing lol.

try putting print statements in both .entered and .exited functions. To check if the code is even executing.

Like this?

local Zone = require(script.Change)
local Regions = game.ReplicatedStorage.Regions2

local player = game:GetService("Players").LocalPlayer
MainPC = player:WaitForChild("PlayerGui"):WaitForChild("Main PC")

local Zone1 = Zone.new(Regions.Zone1.Part)
local Zone2 = Zone.new(Regions.Zone2.Part)

Zone1.playerEntered:Connect(function(plr)
	print("player has entered")
	MainPC.RightCoins["SnowCoin Leaderstat"].Visible = true
	MainPC.RightMoney["SnowCash Leaderstat"].Visible = true
	
	MainPC.RightCoins["Coin Leaderstat"].Visible = false
	MainPC.RightMoney["Money Leaderstat"].Visible = false
end)

Zone1.playerExited:Connect(function(plr)
	print("player has exited")
	MainPC.RightCoins["SnowCoin Leaderstat"].Visible = false
	MainPC.RightMoney["SnowCash Leaderstat"].Visible = false
end)

If so it doesn’t seem to be even executing

okay so that means you might not even be entering the right zone.

Do you know if the whole script is even running?

Yea, I’m sure the code is running. And I know I am entering the right zone.

are you really sure the code is running? I would check that with a print statement at the very top of the script.