I am trying to make the TextLabel's text to change depending on how much gold I have. I don't know if I am doing anything wrong. There is no output. I am fairly new to scripting so i'm sorry if the mistake is rather obvious. This is located in server script storage.
Thanks.
local player = game.Players.LocalPlayer--Finds the player local gui = player:WaitForChild("PlayerGui").GoldHolder--Finds the gui local gold = player:WaitForChild("leaderstats").Gold--Finds the gold in the leaderstats local button = gui.TextLabel--Finds the label game.Players.PlayerAdded:connect(function() print("Hello")--Doesn't print button.Text = "Gold "..gold.Value end)
Well, you know the way you're doing is definitely wrong... (I am )
So,
Before we start off, here's some things you need to be proficient or atleast good at or know the usage of ~ The Client and the Server ~ Remote Event and Remote Function ~ Also, a simple understanding of a GUI
If you know them all, We're good to go! YAY! =D
Let's get over the task here.
Your goal You want to display the amount if gold a certain player has in his account/inventory.
Lets begin with understanding our framework now.
Client The client should hold a gui, which will show the player the current amount of coins. Server The server will be used to update the data on the server
Ok, Lets begin with a local script =P
local Player = game:GetService("Players").LocalPlayer -- Locate our player ;) local PlayerGui = Player:WaitForChild("PlayerGui") -- Wait for the Player GUI to load on client local Gold = Player:WaitForChild("leaderstats").Gold -- Wait for the children to load, aka our leaderstats etc local GoldLabel = PlayerGui:FindFirstChild("Gold", true) -- Find the label in which we want to show our text Gold.Changed:connect(function(ChangedProperty) -- Whenever the Gold Value is changed by the server script, an event is fired, this event is called a Changed event, We take this event to do magic if ChangedProperty == "Value" then -- See if the property that is changed is actually Value and not the name or any other property xD GoldLabel.Text = Gold.Value -- If it's the Value that's changed, update our text! WOOO end end)
Alright That was bad, ik but hey I think I gave some rough Idea =D
Hopefully it helps ya, and to the pros, If I have done anything wrong here pls FIGHT MY CODE (I mean fix me and my code )
~Eat Caiks