Put an attribute as text on a text lable

the text isnt being changed its supposed to be “Attribute value/staminaValue.Value”

local player = game.Players.LocalPlayer
local staminaValue = player:WaitForChild("Stamina")

player:GetAttributeChangedSignal("Stamina"):Connect(function()
	script.Parent.TextLabel.Text = player.Character:GetAttribute("Stamina") .."/" ..staminaValue.Value
end)

player.CharacterAdded:Connect(function(character)
	script.Parent.TextLabel.Text = character:GetAttribute("Stamina") .."/" ..staminaValue.Value
end)

staminaValue is an int value

1 Like

I suspect you meant to do player.Character, instead of just player.
I would suggest moving the code inside of the CharacterAdded event as well.

i.e.

local player = game.Players.LocalPlayer
local staminaValue = player:WaitForChild("Stamina")

player.CharacterAdded:Connect(function(character)
	script.Parent.TextLabel.Text = character:GetAttribute("Stamina") .."/" ..staminaValue.Value
	character:GetAttributeChangedSignal("Stamina"):Connect(function()
		script.Parent.TextLabel.Text = character:GetAttribute("Stamina") .."/" ..staminaValue.Value
	end)
end)
1 Like

yeah im stupid it works now thanks

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.