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

Why does my while true do loop on text not update?

local XP = script.Parent.Parent.Parent.Parent.Parent.Statistic:WaitForChild('XP').Value
local XPRequired = script.Parent.Parent.Parent.Parent.Parent.Statistic:WaitForChild('XPNeeded').Value
ExperienceText = script.Parent

while true do		
	
	ExperienceText.Text = XP..'/'..XPRequired
wait()
end

the text should update every singel second but its not updating

How do i know that its not updating?

because I used a hit part that gives you XP on each touch and the text is still the same

any help?

1 answer

✓ Accepted answer

Try this out, I think .Changed is a better way of doing what you're looking for. Idk if this is a local script or not, but just a heads up a remote event might be needed.

local XP = script.Parent.Parent.Parent.Parent.Parent.Statistic:WaitForChild('XP')
local XPRequired = script.Parent.Parent.Parent.Parent.Parent.Statistic:WaitForChild('XPNeeded')
local ExperienceText = script.Parent

game.Players.PlayerAdded:Connect(function()
	ExperienceText.Text = XP.Value..'/'..XPRequired.Value
end)

    XP.Changed:Connect(function()
   	 ExperienceText.Text = XP.Value..'/'..XPRequired.Value
    end)

16 comments

0

it keeps showing 18:44:58.271 - Players.Halmuni.PlayerGui.XpBar.Frame.ExpText.x:7: attempt to index field 'Value' (a number value)

0

Ok let me edit it

0

Try this now, you should not use .Value in a variable.

0

Try adding "ExperienceText.Text = tostring(XP.Value.."/"..XPRequired.Value)". Don't know if it would work but yeah.

0

It does not show output and it doesen't do anything to the text meaning when I join the game It shows label also I tested if the values would change if i touched a XP giving brick it did not

0

Ok I removed the player added and it worked

0

but then when I join a game and I dont change the value it dosent work

0

how do you mean it doesnt work? like it wont show up unless its changed?

0

yeah

0

its sloppy but try what i just put, it should work.

0

Do I remove the player Added since it works withot player added?

0

yes. see if it works fine without that, if it doesnt, we'll do a playeradded function and then just have it set the experience counter up, and then do the change seperately.

0

it no work

0

ok lol, try that. we'll get it.

0

I got it to work thanks

0

great! please accept answer.

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