Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
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

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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)
0
it keeps showing 18:44:58.271 - Players.Halmuni.PlayerGui.XpBar.Frame.ExpText.x:7: attempt to index field 'Value' (a number value) User#22788 5 — 5y
0
Ok let me edit it DinozCreates 1070 — 5y
0
Try this now, you should not use .Value in a variable. DinozCreates 1070 — 5y
0
Try adding "ExperienceText.Text = tostring(XP.Value.."/"..XPRequired.Value)". Don't know if it would work but yeah. XviperIink 428 — 5y
View all comments (12 more)
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 User#22788 5 — 5y
0
Ok I removed the player added and it worked User#22788 5 — 5y
0
but then when I join a game and I dont change the value it dosent work User#22788 5 — 5y
0
how do you mean it doesnt work? like it wont show up unless its changed? DinozCreates 1070 — 5y
0
yeah User#22788 5 — 5y
0
its sloppy but try what i just put, it should work. DinozCreates 1070 — 5y
0
Do I remove the player Added since it works withot player added? User#22788 5 — 5y
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. DinozCreates 1070 — 5y
0
it no work User#22788 5 — 5y
0
ok lol, try that. we'll get it. DinozCreates 1070 — 5y
0
I got it to work thanks User#22788 5 — 5y
0
great! please accept answer. DinozCreates 1070 — 5y
Ad

Answer this question