I’m attempting to connect a TextLabel to my Leaderstats. Might sound confusing, so here’s an example: I have leaderstats and there’sa value of Coins. I’m trying to set the value of coins into my TextLabel.
The issue is that
My knowledge with Lua scripting isn’t that great
It’s not changing the TextLabel value.
I’ve tried scripting this:
local value = script.Parent
while true do
value.Text = player.leaderstats.Coins.Value
end
What player are you trying to reference here? player is never set so it’s nil.
If it was set, this would result in an infinite loop with no yielding which will crash the game.
If you can provide more information about where this TextLabel is, and which players’ leaderstats you want it to show, then we might be able to point you in the right direction.
A while true do loop is rarely ever the solution, especially without a yield.
This should work:
local myValue = game.Players.LocalPlayer:WaitForChild('leaderstats'):WaitForChild('Coins') -- Waits for the leaderstats folder to be created, then waits for the 'Coins' value.
local value = script.Parent
myValue:GetPropertyChangedSignal('Value'):Connect(function() -- Listen for the 'value' property of the myValue object to change
value.Text = myValue.Value
end