I made script that infects others when infected player touch them, but it deals too much damage than it should (i also noticed player that is infected also gets damaged too much)
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
Character:FindFirstChild("Humanoid").Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid")then
if not (hit.Parent == game.Workspace.infected) and (Character.Parent == game.Workspace.infected) then
local BodyColors = hit.Parent:FindFirstChild("Body Colors")
local newInfected = hit.Parent
newInfected.Parent = game.Workspace.infected
wait(5)
if not hit.Parent:FindFirstChild("Humanoid") then return end
local health = hit.Parent:FindFirstChild("Humanoid").Health
while health > 0 do
health = health - 1
hit.Parent:FindFirstChild("Humanoid").Health = health
wait(5)
end
end
end
end)
end)
end)

1 comment
Add a debounce