I have a script where when a player dies, it drops a gun at their HumanoidRootPart's position. The problem is, it's not calling the "HandleSheriff" function when they die. I added a print after the CharacterAdded function and it never prints when I reset my character.
Code:
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
handlesheriff(player, character)
end)
if player.Character and player.Character.Parent then
handlesheriff(player, player.Character)
end
end)
function handlesheriff(bloxxedplayer, character)
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
humanoid.Died:Connect(function()
if bloxxedplayer == sheriff then
local backpack = bloxxedplayer:FindFirstChild("Backpack")
local root = character:FindFirstChild("HumanoidRootPart")
if backpack and root then
humanoid:UnequipTools()
backpack:ClearAllChildren()
droptaser(root.Position)
end
end
local tag = humanoid:FindFirstChild("creator")
if tag then
local wrongdoer = players:GetPlayerByUserId(players:GetUserIdFromNameAsync(tag.Value))
if wrongdoer.Character and wrongdoer.Character.Parent then
local wrongdoerhumanoid = wrongdoer.Character:FindFirstChild("Humanoid")
if wrongdoerhumanoid then
wrongdoerhumanoid.Health = 0
end
end
end
end)
end
end

1 comment
what does it say in the output?