Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is this code dealing too much damage?

Asked by 1 year ago

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)
0
Add a debounce MaleficentMaestro 109 — 1y

1 answer

Log in to vote
0
Answered by 1 year ago
 health = health - 1

This line of code makes the player lose their full health instantly, what you should try is adding a wait after the line of code I said before.

0
It doesnt work 18890miki 4 — 1y
Ad

Answer this question