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

Why is it a nil?

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

1 comment

0

What are you trying to do?

3 answers

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

1 comment

0

If this worked, Please click "Accept Answer" So other users can search for this topic and use it for reference.

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

1 comment

0

.new is also used for BrickColors, Color3, CFrame, Vector3, etc.

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.

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