Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does this local script not change my UI's text?

I have a local script that changes the UI's text depending on how much currency (coins) you have but when I try test it, I get no print messages and the text doesn't change at all! The UI is inside StarterGUI and the currency folder is inside the player (same place where you would have your leaderstats folder).

The local script:

game.Players.PlayerAdded:Connect(function(plr)
	local coins = plr:WaitForChild("Currency").Coins
	print("a")
	
	script.Parent.Text = coins.Value
	print("a2")
	coins:GetPropertyChangedSignal("Value"):Connect(function()
		script.Parent.Text = coins.Value
		print("a3")
	end)
end)

1 answer

✓ Accepted answer

Move local script to the GUI text label that you want. Try this code instead!

while wait() do
	local player = game.Players.LocalPlayer
	script.Parent.Text = player:WaitForChild("leaderstats"):FindFirstChild("Coins").Value
end

Make sure the leaderstats folder (Instance.new created by leaderstats script) is named leaderstats or else edit my script yourself.

1 comment

0

Turns out all I had to do was replace game.Players.PlayerAdded:Connect(function(plr) with local plr = game.Players.LocalPlayer

This discussion is preserved as it was. New answers, comments, and votes are closed.