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

Sometimes it gives me an error but other times it works and it doesn't give me an error. Help?

Asked by 4 years ago

I have a script called "Variables" inside the Workspace, this has the "_G.orevalue" variable inside of it. Half of the time it gives me this error "02:23:00.740 - Workspace.Store.Ore.SurfaceGui.TextLabel.Update:8: attempt to call field 'orevalue' (a nil value)"

The code is here.

while true do

    script.Parent.Text = (_G.orevalue)
    wait(.1)



end
2
Please post the whole script zomspi 541 — 4y
0
Please post the whole script zomspi 541 — 4y
0
Do you want the variable script? Because this is the entire script. calenmaster1 31 — 4y

3 answers

Log in to vote
0
Answered by
Gingerely 245 Moderation Voter
4 years ago

The problem is probably because the player does not load in correctly when that script runs. For ex; You can call the leaderstats from a script while the player didnt load in properly yet. To fix this problem all you need to do is:

while true do
    wait (5)
    script.Parent.Text = (_G.orevalue)
    wait(.1)



end

Also, this is infinite loop which can break your game in some cases.

0
Because you try to get the player info right away. Gingerely 245 — 4y
Ad
Log in to vote
0
Answered by
ImTrev 344 Moderation Voter
4 years ago
Edited 4 years ago

Is this code in a local script? Also please provide the scripts used.

0
This should be a comment. xAtom_ik 574 — 4y
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

You can't use a dot in variables I don't think. I might be wrong but that doesn't seem like a good idea. Maybe try removing the dot in the variable. Also, I don't think you can use a symbol at the start of variables.

Edit: I realized you were finding a value of something

0
They are finding the value of a variable set in the _G, global variable. xAtom_ik 574 — 4y

Answer this question