Annexsohn
(Annexsohn)
December 18, 2021, 6:25pm
#1
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!
Jonesloto
(Jonesloto)
December 18, 2021, 6:29pm
#2
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)
Annexsohn
(Annexsohn)
December 18, 2021, 6:30pm
#3
Yea well, I knew that for sure. Doesn’t really tell me exactly what to do?
Jonesloto
(Jonesloto)
December 18, 2021, 6:32pm
#4
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
Annexsohn
(Annexsohn)
December 18, 2021, 6:32pm
#5
Yes, I know that. But each area has a different GUI? So how would that work exactly?
Jonesloto
(Jonesloto)
December 18, 2021, 6:34pm
#6
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
Annexsohn
(Annexsohn)
December 18, 2021, 6:39pm
#7
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?
Jonesloto
(Jonesloto)
December 18, 2021, 6:42pm
#8
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”
Annexsohn
(Annexsohn)
December 18, 2021, 6:43pm
#9
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.
Jonesloto
(Jonesloto)
December 18, 2021, 6:45pm
#10
Yes, you could group a bunch of parts in a folder and that could be used as the zone.
Annexsohn
(Annexsohn)
December 18, 2021, 6:47pm
#11
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?
Jonesloto
(Jonesloto)
December 18, 2021, 6:51pm
#12
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
Annexsohn
(Annexsohn)
December 18, 2021, 7:02pm
#13
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.
Jonesloto
(Jonesloto)
December 18, 2021, 7:05pm
#14
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.
Annexsohn
(Annexsohn)
December 18, 2021, 7:06pm
#15
Yea, but that doesn’t really solve my issue with it not showing lol.
Jonesloto
(Jonesloto)
December 18, 2021, 7:09pm
#16
try putting print statements in both .entered and .exited functions. To check if the code is even executing.
Annexsohn
(Annexsohn)
December 18, 2021, 7:12pm
#17
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
Jonesloto
(Jonesloto)
December 18, 2021, 7:14pm
#18
okay so that means you might not even be entering the right zone.
Do you know if the whole script is even running?
Annexsohn
(Annexsohn)
December 18, 2021, 7:15pm
#19
Yea, I’m sure the code is running. And I know I am entering the right zone.
Jonesloto
(Jonesloto)
December 18, 2021, 7:16pm
#20
are you really sure the code is running? I would check that with a print statement at the very top of the script.