Referencing an Int Value located in the player and displaying it on TextLabel

Greetings,

I know this may sound like a trivial issue but I’ve got a TextLabel that I need to be the value present in an Int value which is stored in the Player (Not in StarterGui, StarterScripts etc.)

Here is what I already have:

GUIValue = script.Parent

local player = game.Players.LocalPlayer

local Attack = player:WaitForChild("Attack")

GUIValue.Text =  player:WaitForChild("Attack")

Not sure what your exactly needing…

GUIValue = script.Parent

local player = game.Players.LocalPlayer

local Attack = player:WaitForChild("Attack")

GUIValue.Text =  player:WaitForChild("Attack").Value


Try this? :thinking:

The int needs to be a string so you could chuck it in a tostring

GUIValue.Text =  tostring(player:WaitForChild("Attack").Value)

Is that more efficient than the answer above yours?

Not if your using a string or int value.

Its an addon and a required one because text in guis need to be a string

Works but doesn’t update, trying to make it update whenever the value changes.

This works but only displays what the value was when the character loaded in, it doesn’t update whenever the value changes.

GUIValue = script.Parent

local player = game.Players.LocalPlayer

local Attack = player:WaitForChild("Attack")

Attack.Changed:connect(function()
GUIValue.Text =  player:WaitForChild("Attack").Value
end)

This should work. :+1:

(I don’t know why it’s duplicated :arrow_down:)

In case someone stumbles across this and wants the system using both an update and change to string:

GUIValue = script.Parent

local player = game.Players.LocalPlayer

local Attack = player:WaitForChild("Attack")

Attack.Changed:connect(function()
	GUIValue.Text =  tostring(player:WaitForChild("Attack").Value)
end)```
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Attack = Player:WaitForChild("Attack")

local Label = script.Parent

Attack.Changed:Connect(function(Value)
	Label.Text = Value
end)

You’re using the deprecated :connect(), use :Connect() instead. Additionally, you don’t need to call WaitForChild() on an instance multiple times.