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

Currency Overhead UI Not working?

Please help me out with this, i have been trying to do this all night!

what i am trying to do here is make an overhead currency UI so that the server can see how much currency you have in game, for more detail, Check out my script:

local rStorage = game:GetService("ReplicatedStorage")
local tag = rStorage.NameTag 

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		local head = char.Head
		local newtag = tag:Clone()
		local toptext = newtag.UpperText
		local bottomtext = newtag.LowerText
		local human = char.Humanoid
		local points = plr.leaderstats.Points.Value
		
		human.DisplayDistanceType = "None"
		

		newtag.Parent = head
		newtag.Adornee = head
		toptext.Text = plr.Name
        bottomtext.Text = "Points: "..points

        while wait(0.1) do
        bottomtext.Text = "Points: "..points
        end
    end)
end)

3 answers

✓ Accepted answer

Frankly, Using dots all the time isn't that reliable. Sometimes the objects don't load in and that is why roblox provided us with :WaitForChild Also, I would recommend you using an event to change the text.

local rStorage = game:GetService("ReplicatedStorage")
local tag = rStorage.NameTag 
local SnipePlayer -- Let's snipe the player
local bottomtext
game.Players.PlayerAdded:Connect(function(plr)
local SnipePlayer = plr

    local Char = plr.Character or plr.CharacterAdded:Wait()
        local head = char:WaitForChild('Head')
        local newtag = tag:Clone()
        local toptext = newtag.UpperText
        bottomtext = newtag.LowerText
        local human = char:WaitForChild('Humanoid')
        local points = plr.leaderstats.Points.Value

        human.DisplayDistanceType = "None"


        newtag.Parent = head
        newtag.Adornee = head
        toptext.Text = plr.Name
        bottomtext.Text = "Points: "..points
    end)
end)

SnipePlayer:WaitForChild('leaderstats').Points.Changed:Connect(function()
bottomtext.Text = SnipePlayer.leaderstats.Points.Value -- REst is to you to adjust
end)
human.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None

You should define Points as plr.leaderstats.Points.

And instead of using a for loop to change the value of the Bottom Text, use GetPropertyChangedSignal.

points:GetPropertyChangedSignal("Value"):Connect(function()

bottomText.Text = "POINTS: "..points.Value

end)

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