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

How do I make the Parent textlabel's Text to the exp value whenever it changes?

local player = game.Players.LocalPlayer
local exp = player.PlayerScripts:WaitForChild("Running script").exp
	exp.Changed:connect(function(newValue)
		script.Parent.Text = newValue
	end)

1 answer

✓ Accepted answer

Your Problem

When you reference the value, you're getting it from game.StarterPlayer.StarterPlayerScripts. That is not the location of the value inside the client. When the player joins, everything in StarterPlayerScripts is cloned into Player.PlayerScripts

Your code is correct :) you just need to reference the value correctly.


Code

This should be in a localscript.

local plr = game.Players.LocalPlayer;
--retrieve from plr.PlayerScripts
local exp = plr.PlayerScripts:WaitForChild("Running script").exp;

exp.Changed:connect(function(newValue)
	script.Parent.Text = newValue;
end)

2 comments

0

text isn't changing, and infinite yield possible

0

nevermind, thanks

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