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

How do I fix this Gui Scripts error?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

So I have this Gui display your points It works fine BUT I have to disable and enable the script to make it work Error: leaderstats is not a valid member of Player

I know whats wrong, its that when the script runs, leaderstats is not made in player yet, it takes a couple seconds to load, so when the script does its magic, leaderstats is not a part of Player yet

How would I fix this?

local gui = script.Parent
local text = gui:FindFirstChild("TextLabel")

local points = script.Parent.Parent.Parent.leaderstats.Points
text.Text = "Points"..points.Value

while true do
    wait()
    text.Text = "Points:"..points.Value
end
0
For line 2, instead of 'FindFirstChild', try the 'WaitForChild' method. TheeDeathCaster 2368 — 9y
0
Well if the problem is with leaderstats, you should change line 4 to use script.Parent.Parent.Parent:WaitForChild("leaderstats").Points Merely 2122 — 9y
0
Thanks ggggyourface23 63 — 9y

Answer this question