Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to constantly update a HUD with player stats with filtering enabled on?

If i wanted players to have stats; exp, level, money and stored the stats in ReplicatedStorage as Values, and had a hud to display those stats, how would I go about updating the hud with those stats constantly, so that if level changes it instantly changes on the hud? I'm trying to use this with filtering enabled.

2 answers

Here is a simple script that I made to display the player's stats on a text label.

while true do
script.Parent.Text = game.Players.LocalPlayer.leaderstats.Money.Value
wait(1)
end
--change "money" to your leaderstat

1 comment

0

edit: While true do is used to update the text label every 1 second.

You could make use of the Changed event of NumberValues.

The Changed event fires when the Value property of a NumberValue changes.

expVal = game.ReplicatedStorage.Exp --the NumberValue object for exp
expVal.Changed:connect(function()
	script.Parent.Text = expVal.Value.." EXP"
end)
--this script goes into a TextLabel that displays exp stat

A local script should have no problems accessing ReplicatedStorage, but it may be beneficial to use :WaitForChild() in case the contents of ReplicatedStorage haven't yet been replicated to the client.

As for the GUI, a local script can change it without requiring server interaction.

This discussion is preserved as it was. New answers, comments, and votes are closed.