Can't Find out How to Make a Cash on Kill Script for guis instead of leaderstats

So I am making a combat game and i’m trying to make it so that when you kill a player you get money. I have already made the currency GUI and I made sure it worked with some tests. The problem is I can’t find out how to make it so that when you kill someone you get money. I have tried some tutorials but in all of them the money is a leaderstat but I want it in a GUI. I’m just asking how to change it so it’s on a gui and not a leaderstat. Thank You! -Lxke_Palm

1 Like

You should save the money as a stat, but you don’t need to use a leaderstat. Just go the way of making it the leaderstats way, but instead change the name of leaderstats to something like “StatFolder”, and store a cash value under that. And then have a GUI that updates every time the cash value updates.

Thank you! I will try to do that.

Sorry I had to go to bed last night, but I made the script, but how do you update the cash value I haven’t done that in a while. :sweat_smile:

You would want to do something like

cash:GetPropertyChangedSignal("Value"):Connect(function()
    Gui.TextLabel.Text = cash.Value
end)

Something along those lines, but puting the correct paths to the cash value and the GUI.

A much better solution. If a player joined with 20 cash, the GUI wouldn’t update. This one piece of line Gui.TextLabel.Text = cash.Value will update the GUI when a player joins.

Gui.TextLabel.Text = cash.Value

cash:GetPropertyChangedSignal("Value"):Connect(function()
    Gui.TextLabel.Text = cash.Value
end)

None of these scripts worked. Maybe there is something wrong with the cash on kill its self?

They should work. You shouldn’t rely on others to spoon feed you. What have you done with the script? Can I have some sneak peaks?

@Lxke_Palm To detect change in value, try this

cash.Changed:Connect(function()
gui.TextLabel.Text = cash.Value
end)

Hope it helps!

1 Like