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

Why is it a nil?

Asked by 10 years ago

I'm new at scripting, and already I make mistakes.

So I get this problem

18:26:38.318 - Workspace.Script:3: attempt to index global 'IntValue' (a nil value)

whenever executing this script.

am = Workspace.AmmoCrate1.AmmoCrate

while true do
    wait(10)
    am.IntValue = IntValue.new(500)
end
0
What are you trying to do? wjs3456 90 — 10y

3 answers

Log in to vote
2
Answered by
bbissell 346 Moderation Voter
10 years ago

You need to change the Value of the IntValue.

If you would like to reset the value to 500, you would do it like this:

am.IntValue.Value = 500

If you would like to add 500 to the current Amount, you would do it like this:

am.IntValue.Value = am.IntValue.Value + 500
0
If this worked, Please click "Accept Answer" So other users can search for this topic and use it for reference. bbissell 346 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

Your problem is line 5

am.IntValue = IntValue.new(500)

.new is used for creating new Instances. Example

a = Instance.new("Part")

To add 500 you would do

am.IntValue.Value = am.IntValue.Value +500
0
.new is also used for BrickColors, Color3, CFrame, Vector3, etc. Spongocardo 1991 — 10y
Log in to vote
0
Answered by 10 years ago

Line five is the problem, now I am not sure what you want.

Are you trying to create an IntValue and then assign it a value of 500? Answer:

value = Instance.new("IntValue", am)
value.Value = 500

Or are you trying to assign the value of 500 to an IntValue that already exisits? Answer:

am.IntValue.Value = 500

Good luck.

Answer this question