So I’m making a Team Deathmatch game and when a round starts every player gets a Tool.
The problem is that whenever someone dies they lose their tool. I’ve tried adding the tool again using
humanoid.died but that doesn’t work either. I don’t have any errors.
You should create a folder with the player name upon joining as its a requirement for this snippet to work.
--Make a folder with the player name in serverstorage!
Humanoid.HealthChanged:Connect(function(__HP) -- Sanity Check
if __HP <= 0 then -- 1 ?
if __PLAYER.Backpack:FindFirstChildOfClass("Tool") then
__PLAYER.Backpack:FindFirstChildOfClass("Tool"):Clone().Parent = ServerStorage:FindFirstChild(__PLAYER.Name) -- Saved to player folder!
elseif __PLAYER.Character:FindFirstChildOfClass("Tool") then
__PLAYER.Character:FindFirstChildOfClass("Tool"):Clone().Parent = ServerStorage:FindFirstChild(__PLAYER.Name)
end
end
end)
__PLAYER.CharacterAdded:Connect(function(__CHAR)
for _,v : Tool? in pairs(ServerStorage:FindFirstChild(__PLAYER.Name):GetChildren()) do
if v:IsA("Tool") then
v:Clone().Parent = __PLAYER.Backpack
end
end
end)
game:GetService(“Players”).PlayerAdded:conmect(function(player)
player.CharacterAdded:connect(function(char)
— Give the player their tool, they just respawned
end)
end)
or put the tools both inside Player.Backpack and Player.StarterPlayer. (It’s basically like StarterPack, but player specific)
Note, you should clear the StarterPlayer once you dont want them to keep the tool.
StarterGear is a container automatically inserted into each Player when the player joins the game and When a player spawns.
local StarterGearTool = Tool:Clone()
StarterGearTool.Parent = Player:WaitForChild("StarterGear")
Also note that this will not automatically be in the Player backpack, but you will have to clone Tool and Place it in the backpack When Round has started. When the Round is Finished, Remove the Tool From StarterGear and Player Backpack.
Also, The reason why humanoid.Died won’t work because, the event fires when the Humanoid dies, usually when Humanoid.Health reaches 0. This won’t guarantee that player will respawn, but it will tell us that the Player has died.