(Solved By YXFrosty) Infection system

Thanks all for The reply i would appricated it
Let me go test it for now

Touched isnt a valid member of workspace.Nitrosteck.HumanoidRootPart ?

Well… I don’t know how to fix that. Let me think for another solution.

1 Like

Should we use Hitbox ? or i mean Can we use it ?

TOOK FOREVER TO WRITE, PLEASE READ CAREFULLY!

local function infect(hit)
  
  if hit.Parent:FindFirstChild("Humanoid") and not hit.Parent:FindFirstChild("ZombieScript") then

    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    player.Character = game:GetService("ServerStorage").ZombieModel
    wait()
    script:Clone().Parent = player.Character

end
end

for _, zombie in pairs (script.Parent:GetChildren()) do
   local zombieLeftArm = zombie:FindFirstChild("LeftArm")
   local zombieRightArm = zombie:FindFirstChild("RightArm") 

   if zombieLeftArm and zombieRightArm then -- do both the the left and right arms exist?
      zombieLeftArm.Touched:Connect(infect)
      zombieRightArm.Touched:Connect(infect)
   end
end

FEW THINGS TO NOTE FIRST

  • Name the script “ZombieScript” and put it under the zombie model
  • Name your zombie model “ZombieModel” and have it in ServerStorage
  • Make sure you have the arms named “LeftArm” and “RightArm”

You can insert the script NAMED “ZombieScript” IN ANY NPC

  • Just make sure the NPC’s arms are named “LeftArm” and “RightArm”
  • In other words, an R6 model will do.
1 Like

This might work, because you uses arms instead of whole body. Just not sure about the cloning character part.

Edit: This script won’t work with players, right?

He want to change the player after being touched to a zombie model ?
And i mean yes i guess its for Npc lol

Which ruins the whole infecting part.

i feel like your script will work if i can fixed that Valid member lol

Maybe this???

local Infected = game.Workspace.Infected
local DefaultWait = 0.4

local function GoInfected(BodyColor) --Infected function
	BodyColor.HeadColor = BrickColor.new("Lime green")
	wait(DefaultWait)
	BodyColor.LeftArmColor = BrickColor.new("Lime green")
	wait(DefaultWait)
	BodyColor.RightArmColor = BrickColor.new("Lime green")
	wait(DefaultWait)
	BodyColor.LeftLegColor = BrickColor.new("Lime green")
	wait(DefaultWait)
	BodyColor.RightLegColor = BrickColor.new("Lime green")
	wait(DefaultWait)
	BodyColor.TorsoColor = BrickColor.new("Lime green")
end

--Get infected People
while wait() do
	for v, child in pairs(Infected:GetChildren()) do
		--Get infected Part
		for _, part in ipairs(child:GetDescendants()) do
			--Infected Script
			if part:IsA("BasePart") and part.CanTouch == true then
				part.Touched:Connect(function(hit)
					print("Touched")
					if hit.Parent:FindFirstChild("Humanoid") then
						wait(0.8)
						local BodyColors = hit.Parent:FindFirstChild("Body Colors")

						GoInfected(BodyColors)

						local Zombie = hit.Parent

						if Zombie.Parent == Infected then
							print("Already Infected")
						else
							Zombie.Parent = Infected
						end
					end
				end)
			end
		end
	end
end

I change it to check if it is a part and can be touch.

1 Like

MATE ITs working but
After i touched 008 in starting to regconizing and print Touched 5000 times lol
I cant even move

The script makes it so a player can infect other players after being infected.

Oh… The model is a zombie?

char limit

Implement a debounce.

1 Like

Yeah, the script assumes you have a model of a zombie you would like players to become after getting infected.

That would be for the other script, mine works like an infection game.

That would prevent it from saying touched 5000 times.

Iam confusing where to put it to not stop the whole under function lol

local Infected = game.Workspace.Infected
local DefaultWait = 0.4
local Debounce = false

local function GoInfected(BodyColor) --Infected function
	BodyColor.HeadColor = BrickColor.new("Lime green")
	wait(DefaultWait)
	BodyColor.LeftArmColor = BrickColor.new("Lime green")
	wait(DefaultWait)
	BodyColor.RightArmColor = BrickColor.new("Lime green")
	wait(DefaultWait)
	BodyColor.LeftLegColor = BrickColor.new("Lime green")
	wait(DefaultWait)
	BodyColor.RightLegColor = BrickColor.new("Lime green")
	wait(DefaultWait)
	BodyColor.TorsoColor = BrickColor.new("Lime green")
end

--Get infected People
while wait() do
	for v, child in pairs(Infected:GetChildren()) do
		--Get infected Part
		for _, part in ipairs(child:GetDescendants()) do
			--Infected Script
			if part:IsA("BasePart") and part.CanTouch == true then
				part.Touched:Connect(function(hit)
					if Debounce == true then return end
					
					print("Touched")
					local Zombie = hit.Parent

					if Zombie.Parent == Infected then
						print("Already Infected")
					else
						if Zombie:FindFirstChild("Humanoid") then
							wait(0.8)
							local BodyColors = Zombie:FindFirstChild("Body Colors")

							GoInfected(BodyColors)
							Zombie.Parent = Infected
						end
					end

					Debounce = true
					wait(1)
					Debounce = false
				end)
			end
		end
	end
end
1 Like

Still printing 3000 Should i increase the wait time ?
Edit : it still the same if i increase wait time :stuck_out_tongue: