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)"

3 comments
I had tried player:WaitForChild("Character") and it didn't work. This did. Thank you.
@TheDoubleJ0Jake0Jam Character isn't a child of player - it's a property.
@Perci1 That is good to know. Thanks!