No errors and unknown problem with my infection script

I’m having problems it doesnt print anything and there are no errors, this is the code.
The “while wait do” checks every 2 seconds if a play have a boolvalue in their character if they do they take damage.
the “characteradded” one is supposed to pick a random number when the character is added ive made it so everytime a character loads in the local script fires a remoteevent to the server. if the number that was randomly picked is 1 then a boolvalue will be created and inserted into the player’s character if its 2 then it does nothing.
The runservice line checks constantly if the player has a boolvalue or not, ive added prints and it doesnt print and i dont see any boolvalues being added into the player nor any guis. Please help me solve this thank you.

local rs = game:GetService("RunService")
--[[
	local value = Instance.new("BoolValue",v.Character)
								value.Name = "Infected"
value = true
--]]
while wait(2) do
	local randomdmg = math.random(10,20)
	for i,v in pairs(game.Players:GetPlayers()) do
		if v.Character:FindFirstChild("BoolValue") then
			v.Character:FindFirstChild("Humanoid"):TakeDamage(randomdmg)
			print(randomdmg)
		end
	end
end
game.ReplicatedStorage.characteradded.OnServerEvent:Connect(function(plr)
	local randomnum = math.random(1,2)
		local last = nil
	             for i,v in pairs(game.Players:GetPlayers()) do
		         if last == nil then
				last = v
			end
		     if randomnum == 2 then
			            local value = Instance.new("BoolValue",v.Character)
					    value.Name = "Infected"
			            value = true
			            local gui = game.ServerStorage.InfectGui:Clone()
			            gui.Parent = last.PlayerGui
			print(plr.Name.." got unlucky and is infected")
		    elseif randomnum == not 2 then
			            print(plr.Name.." got lucky and isnt infected")
			
		end
	end
end)

rs.Stepped:Connect(function()
	local last = nil
	for i,v in pairs(game.Players:GetChildren()) do
		if last == nil then
			last = v
		end
		if last.Character and v.Character then
			if last.Character and last.Character~= v.Character then
				local dist = (last.Character.HumanoidRootPart.Position-v.Character.HumanoidRootPart.Position).magnitude
				if dist <= 5 and last.Character:FindFirstChild("BoolValue") and v:FindFirstChild("BoolValue") == nil then
					print("The player "..v.Name.." is close to "..last.Name)
						local value = Instance.new("BoolValue",v.Character)
					    value.Name = "Infected"
					    value = true
					    local gui = game.ServerStorage.InfectGui:Clone()
			            gui.Parent = v.PlayerGui
				end
				last = v
			end
		end
	end
end)

When you use any type of loop, code after that loop wont run unless you provide an exit condition for that loop.

One of many solutions would be to move the while loop to the end of the script.

https://developer.roblox.com/en-us/articles/Loops#while-do

1 Like