Hello! I am trying to figure out how I can make my Money GUI Change when you go into a different area. Such as when you go to a different zone, the Money GUI Changes to a different Money GUI, for lets say Snow Coins, when you go into the Snow World. How can I do this?
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
local world = Instance.new("StringValue")
world.Name = "World"
world.Value = "Snow" --some world
world.Parent = player
if player:WaitForChild("World").Value == "Snow" then
player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("Frame"):WaitForChild("ImageLabel").Image = "" --some image
end
end)
Primitive, but this is essentially what you’d do.
World is just a sample string value instance parented to the player, you would need to change it every time the player enters a new world, to that world, by doing.
Can you give an example on what 2 Areas would look like on the script? Also do I need to put anything in workspace, and call it something. Where do I also put the script? Would it be a script, or a localscript?
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
local world = Instance.new("StringValue")
world.Name = "World"
world.Value = "Tutorial" --default world is tutorial mode
world.Parent = player
player.CharacterAdded:Connect(function(character)
local playerWorld = player:WaitForChild("World")
if playerWorld.Value == "Tutorial" then
player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("Frame"):WaitForChild("ImageLabel").Image = "" --some image
elseif playerWorld.Value == "Snow" then
player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("Frame"):WaitForChild("ImageLabel").Image = "" --some image
end
end)
end)
It’s under the CharacterAdded event, and it’s just an example, you could obviously easily move it if necessary. Without knowing how he intends to have players “change” worlds, I can’t implement it for that.
Yes they have the same layout, but what you do mean by changing their property? What I mean is how can I get it to change its property by apon entering a part
Why? He asked for how to make it work for 2 or more worlds, so I did. No need to edit the old post, when making a new one makes just as much sense, on the other hand you replying before reading the replies does not make much sense.
How can I get it so apon entering a area it shows up? Also where do I put this code. Is it a Script, or a localscript? Again, do I also put anything inside Workspace?
You could detect a player entering a certain area using Region3 functions (which are deprecated) or use workspace functions.
To modify the GUI property, let’s say both currency GUI has a name that indicates the currency type like Snow, Coins right? Let’s say you are having the TextLabel as Coins, and when the player enters another region(snowy region), you could make the TextLabel to display Snow instead.
local players = game:GetService("Players")
local snowWorldPart = workspace:WaitForChild("SnowWorldPart")
players.PlayerAdded:Connect(function(player)
local world = Instance.new("StringValue")
world.Name = "World"
world.Value = "Tutorial" --default world is tutorial mode
world.Parent = player
player.CharacterAdded:Connect(function(character)
local playerWorld = player:WaitForChild("World")
if playerWorld.Value == "Tutorial" then
player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("Frame"):WaitForChild("ImageLabel").Image = "" --some image
elseif playerWorld.Value == "Snow" then
end
end)
end)
snowWorldPart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("HumanoidRootPart") then
local player = players:GetPlayerFromCharacter(hit.Parent)
local worldStat = player:WaitForChild("World")
worldStat.Value = "Snow"
player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("Frame"):WaitForChild("ImageLabel").Image = ""
end
end)
Here you go, changes on touching a part. This is a server script.