Why do I get this error when I put a weapons kit gun from server storage into a players backpack

Hello Developers! I get this error when I am putting a gun from server storage into a players backpack. When the gun is in starterpack its fine and it works, but when I put it into server storage and then the round starts and it puts it into the players backpack the gun stops working. Here is the gun I am using, it is part of the weapons kit, I am using the AR gun specifically:

Also here is the error i getting:
12:33:37.834 - ReplicatedStorage.WeaponsSystem.WeaponsSystem:181: attempt to call a nil value

Why am I getting this error and what can I do so that it works?

In your script in line 181 one of your variables is defined as “nil” meaning it doesn’t exist. Double check your code and make sure everything is defined either by using print statements or breakpoints if that doesn’t help you could you please provide some more code so we can help you if the issue persists.

Ok here is the block of code that is defined as “nil”
(Line 181 is: WeaponsSystem.onCharacterAdded(Players.LocalPlayer.Character))

		if Players.LocalPlayer.Character then

Is this a local script or server script?

A module script

30 charrrrssssssssssss

Instead of cloning the weapon into the player’s character. Clone it into the player’s backpack object. Which can be done via,

        local weapon = weaponObject:Clone()
        weapon.Parent = player:WaitForChild("Backpack")

I’m still a little confused over your code. You mention the function is located in a ModuleScript correct? If so can you provide that code as well.

Ok but that code is above 400 lines so i think its better if you get the model and open studio.
The script which starts the round and gives players their gun already clones it into the players backpack.

Try removing that bit of code, and see if it works.

Also, don’t spam here on the DevForum.

Yes I have already done that. Thankyou so much!