if you couldnt tell the dead player touches the health pickup which they arent supposed to do
2 Likes
When the player touches it, check to make sure the player is alive before giving them health, I guess.
Very simple. Just do a check for humanoid.Health and make sure its above 0 before allowing the pickup script
1 Like
First you need to put a script in StarterCharacterScripts
And put this code:
local char = script.Parent
local Hum = char:WaitForChild("Humanoid") -- or name of the Humanoid
--///Second part of the script\\\--
--We'll make it so that when the player dies, parts can't run scripts that require touching the part
Hum.Died:Connect(function()
for i = 1, #char:GetChildren() do
local part_of_the_character = char:GetChildren()[i]
if part_of_the_character:IsA("BasePart") then
part_of_the_character.CanTouch = false
end
end
end)
In the first part of the code we only detect the humanoid
In the second part of the code we detect all the parts that make up the game, as shown in this image:
this code will help you not have to check for each script if the player is alive, If it is not what you are looking for, you can tell me and I will fix it.
1 Like