Hello!
I am working on a wallet tool. I have it pretty much done but i have one slight problem. It only updates the money count when i equip it. So when i earn money when I’m holding it it doesn’t update. How could i make it so it updates live?
This is my current code:
local player = game.Players.LocalPlayer
local countgui = script.Parent.EarnedDC
local tool = script.Parent.Parent
tool.Equipped:Connect(function()
countgui.TextLabel.Text = player.leaderstats.DogeCoins.Value
end)
player.leaderstats.DogeCoins.Changed:Connect(function(value)
player.leaderstats.DogeCoins.Value = value
end
The whole script should look like this:
local player = game.Players.LocalPlayer
local countgui = script.Parent.EarnedDC
local tool = script.Parent.Parent
player.leaderstats.DogeCoins.Changed:Connect(function(value)
countgui.TextLabel.Text = value
end
tool.Equipped:Connect(function()
countgui.TextLabel.Text = player.leaderstats.DogeCoins.Value
end)
local player = game.Players.LocalPlayer
local countgui = script.Parent.EarnedDC
local tool = script.Parent.Parent
player.leaderstats.DogeCoins.Changed:Connect(function(value)
countgui.TextLabel.Text = value
end)
tool.Equipped:Connect(function()
countgui.TextLabel.Text = player.leaderstats.DogeCoins.Value
end)
local players = game:GetService"Players"
local tool = script.Parent --Reference to tool.
local billboardGui = tool.BillboardGui --Reference to tool's BillboardGui.
local connection
tool.Equipped:Connect(function()
local character = tool.Parent
if not character then return end
local player = players:GetPlayerFromCharacter(character)
if not player then return end
local leaderstats = player:FindFirstChild"leaderstats"
if not leaderstats then return end
local stat = leaderstats:FindFirstChild"" --Change to stat's name.
if not stat then return end
billboardGui.TextLabel.Text = stat.Value
if connection then
if connection.Connected then
return
end
end
connection = stat.Changed:Connect(function(value)
billboardGui.TextLabel.Text = value
end)
end)
tool.Unequipped:Connect(function()
if connection then
if connection.Connected then
connection:Disconnect()
end
end
end)
Since this was last replied to six days ago, for the sake of trying to get you a reply as quick as possible I’ll chime in.
This is most likely due to the fact you’re doing this locally. You’re going to want to completley handle this with a server script. I think Forummers reply here is really good as it takes into account for the fact that you want this done on the server side. Try putting a ServerScript with Forummers reply inside the tool. I see no reason why it wouldn’t work.