local player = game.Players.LocalPlayer script.Parent["GunScript V5"].Disabled = true script.Parent.Equipped:connect(function() script.Parent["GunScript V5"].Disabled = false end) script.Parent.Unequipped:connect(function() script.Parent["GunScript V5"].Disabled = true end) player.Character.Humanoid.Died:connect(function() -- errors here script.Parent["GunScript V5"].Disabled = true end) --This script prevents the gun from being fired when it is not equipped or if the player died.
error is: "Attempt to index field 'Character' (a nil value)"
The player's character may not be loaded when this script runs. To ensure the character exists, place this after line 2 in your script:
repeat wait() until player.Character