Is there a way to make a tool that you're holding unequip when you die?
local Players = game:GetService("Players") local ContextActionService = game:GetService("ContextActionService") local localPlayer = Players.LocalPlayer game:GetService('Players').PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) character:WaitForChild("Humanoid").Died:Connect(function() if localPlayer.Character then local humanoid = localPlayer.Character:FindFirstChildOfClass("Humanoid") if humanoid then humanoid:UnequipTools() print(player.Name .. " has died!") end end end
If your problem is that players are able to use a tool while they are dead(and before they respawn), then just check if the humanoids health is > 0 when they use the tool.
You can use Humanoid.Died
and Humanoid:UnequipTool
to make the script works.
game:GetService('Players').PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) character:WaitForChild("Humanoid").Died:Connect(function() character:WaitForChild("Humanoid"):UnequipTool(tool) -- change the tool becomes the tool's name end) end) end)
How do you do this. i have been reading this for like 1 or 2 hours but i cant seem to make it work