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
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)
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)