This is part of my gun drop script, which is supposed to make a gun spawn at the location that you died. However, it does not work as it returns the error
Players.Player.Backpack.MurderGun.ClientGunScript:66: attempt to call field 'Died' (a userdata value)
Here is my code
tool.Unequipped:connect(function(mouse) if mouse then mouse.Icon = defaulticon end end) game.Players.LocalPlayer.Character.Humanoid.Died():connect(function() print("Sheriff died") local floatinggun = game.ReplicatedStorage.gameplay.Misc.floatinggun local newgun = floatinggun:Clone() newgun.Position = game.Players.LocalPlayer.Character.Head.CFrame.p end)
Side note: The code is in a localscript
You made a syntax error. When you connect an event to a function, you don't put a parenthesis after the event, the correct syntax is Object.event:connect(function)
.
To fix this, just get rid of the parenthesis after Died
, like so:
game.Players.LocalPlayer.Character.Humanoid.Died:connect(function() --Code end)
Hope this helped!