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

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

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

3 comments

2

Please post the whole script

0

Please post the whole script

0

Do you want the variable script? Because this is the entire script.

3 answers

✓ Accepted answer

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.

1 comment

0

Because you try to get the player info right away.

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

1 comment

0

This should be a comment.

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

1 comment

0

They are finding the value of a variable set in the _G, global variable.

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