Sign that displays a Value locally

I wanna make a sign in my game display a players stat locally, this stat is stored inside the player and is not visible anywhere, it is an intvalue and is increased by 1 every 10 seconds

The sign is a part with a surfacegui, textlabel and a local script and I have tried putting this in the local script:

local Sign = script.Parent

repeat wait() 

until game.Players.LocalPlayer and game.Players.LocalPlayer:FindFirstChild('Attempts')

Sign.Text = game.Players.LocalPlayer.Attempts.Value

and I’ve also tried:

script.Parent.Text = game.Players.LocalPlayer.Attempts.Value

Any on idea on how I can make this visible on the sign?

You almost have it. Here’s some pointers:

LocalScripts will only run in certain locations, documented below:

[Source]

Your LocalScript probably can’t be within the SurfaceGui, because the SurfaceGui is most likely not within one of those locations where LocalScripts can run. So you will have to change your code.

Here’s my recommendation: Move your LocalScript into PlayerScripts, and then change your code as follows:

local Sign = workspace.Wherever.Your.Sign.Is
local attempts = game.Players.LocalPlayer:WaitForChild("Attempts")
Sign.Text = tostring(attempts.Value)
1 Like

You also need to detect when the value changes since they said it would be updated:

local Sign = --reference to the sign
local Attempts = game:GetService("Players").LocalPlayer:WaitForChild("Attemps")

Sign.Text = tostring(Attempts.Value)

Attempts.Changed:Connect(function(NewInt)
    Sign.Text = tostring(NewInt)
end)
2 Likes