I got this code from a YouTube tutorial
local player = game.Players.LocalPlayer local leaderStats = player:WaitForChild("leaderstats") local gold = leaderStats:WaitForChild("Gold") gold:GetPropertyChangeSignal("Value"):Connect(function() script.Parent.Text = "Gold"..tostring(gold.Value) end)
So this is a pretty easy fix, just change :GetPropertyChangedSignal
to .Changed
.
Here's the code I typed up:
local player = game.Players.LocalPlayer local leaderStats = player:WaitForChild("leaderstats") local gold = leaderStats:WaitForChild("Gold") --if you want to get the player's gold when they join as well script.Parent.Text = 'Gold: '..tostring(gold.Value) gold.Changed:Connect(function() script.Parent.Text = "Gold: "..tostring(gold.Value) end)
I tested it in-game with this leaderstats script and it worked just fine for me:
game:GetService('Players').PlayerAdded:Connect(function(player) local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:FindFirstChildOfClass('Humanoid') local leaderstats = Instance.new('Folder') leaderstats.Name = 'leaderstats' leaderstats.Parent = player local gold = Instance.new('IntValue') gold.Name = 'Gold' gold.Parent = leaderstats gold.Value = 1 --gives a player gold every second while true do wait(1) gold.Value = gold.Value + 1 end end)
I think you need to put this code in a LocalScript inside of a TextLabel.