Hi guys,I made a simple cash indicator on the leaderboard,but for some reason it messed up with the score indicator (always on the leaderboard).How can I connect the cash script to a custom GUI without showing it on the leaderboard?
This is the cash script
You can use the .Changed event on the UI to check when the cash value is edited to update the UI. It would look something like this:
--- Local script in UI
local plr = game.Players.LocalPlayer
local GUI = script.Parent
plr.leaderstats.Cash.Value.Changed:Connect(function()
GUI.Text.Value = tostring(plr.leaderstats.Cash.Value)
end)
Well to not show it on the leaderboard, you shouldn’t have a folder called “leaderstats.” the only reason you’d have that is because you want to show it publicly on the leaderboard. And then yeah, the GUI can automatically update via. a localscript whenever the cash value is changed using topdog_alpha’s script above.
Aye that’s true. Misread that.
He should still parent it to the player however as this would prevent exploiters editing how much cash they have as they can access it if it is on the client and he would still want to use the .Changed event to update the UI whenever the value Cash is changed
As @Thanhpro291368 said you do not need a folder called leaderstats if you do not want it displayed on the leaderboard. All you need to do is just parent the value Cash directly to the player or create a different folder inside the player to put your values inside that isn’t called leaderstats.
Yes, just like that. Now cash will be parented to the player rather than the leaderstats.
Anything you now parent to the folder leaderstats will be visible on the leaderboard. Anything parented to the player will not be visible on the leaderboard
Thank you very much,so then I have to create a GUI with that local script that you mentioned before?But I have only one question.The cash is not shown on the leaderboard,before when you gave me that local script,there were these strings
These two lines of code mentioned the “leaderstats”.But if the the cash is not parented anymore with the leaderstats ,what I have to do with these two lines of code?
Just replace the plr.leaderstats.Cash with the pathway to the cash value.
If you are now putting the cash value in player all you will need to do is remove leaderstats from the lines