Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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

Log in to vote
0
Answered by 6 years ago

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
0
edit: While true do is used to update the text label every 1 second. PyccknnXakep 1225 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

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.

Answer this question