I am trying to create a script that infects other players when the zombified player touches the other players, and for some reason it puts so many scripts into the character that the server crashes. I tried using debounce but that didn’t work for some reason.
That’s my script which is in the character of the zombie player (It’s a normal script)
local torso = script.Parent:WaitForChild("UpperTorso")
local Players = game:GetService("Players")
local debounce = false
torso.Touched:Connect(function(hit)
local player = hit.Parent
local Player = Players:GetPlayerFromCharacter(player)
if hit.Parent:FindFirstChild("Humanoid") and not hit.Parent:FindFirstChild("Infected") and debounce == false then
debounce = true
if not hit.Parent:FindFirstChild("PlayerAnomaly") then
local AnomalyPlayer = Instance.new("BoolValue")
AnomalyPlayer.Parent = player
AnomalyPlayer.Name = "PlayerAnomaly"
end
player.Humanoid:UnequipTools()
if Player then
for i, Tool in pairs(Player.Backpack:GetChildren()) do
Tool:Destroy()
end
end
for i, Part in pairs(player:GetChildren()) do
if Part:IsA("BasePart") then
Part.BrickColor = BrickColor.new("Grime")
end
end
local Infect = game.ServerStorage.Infect:Clone()
Infect.Parent = player
Infect.Enabled = true
game.ServerStorage.Groan:Clone().Parent = player.Head
end
wait(0.1)
debounce = false
end)