Error while trying to get a value using a local script

So I’ve got a bit of a problem. In my game, I have a weapon system. I decided to put a NumberValue inside my tool to get my ammo. SImple, right? Well not really… It ended up giving me an error telling me the value isn’t even part of the tool when I even checked myself if it was there in-game, and it was.

I’ve tried everything I could, like changing the value’s ancestor, without any success. Here’s the code I put in:

--The client script is inside the handle, so I need to set the tool to a variable
local tool = script.Parent.Parent
local ammoValue = tool.AmmoValue.Value

I’d appreciate any kind of help. If you want me to clarify, I can in the replies.

try using WaitForChild ? idk if that will work but try

1 Like

You can do something like this:

local tool = game.Players.LocalPlayer.Backpack.UZI
local ammoValue = tool.AmmoValue.Value

is the script running when the game starts?

My goodness it actually worked, thanks man, you’re litteraly a life saver :smile: