I am trying to make a code that infects players whenever they have the virus, but whenever i try to spread it , the outputs says: attempt to index nil with 'FindFirstChild'
local players = game:GetService("Players")
local player = game.Players.LocalPlayer.Character
player:WaitForChild("Humanoid").Touched:Connect(function(hit)
if(hit.Parent:FindFirstChild("Humanoid")) then
if not players:GetPlayerFromCharacter(hit.Parent):FindFirstChild("IsInfected")and players:GetPlayerFromCharacter(player):FindFirstChild("IsInfected") then
local infectedPlr = players:GetPlayerFromCharacter(hit.Parent)
local boolValue = Instance.new("BoolValue",infectedPlr)
boolValue.Name = "isInfected"
boolValue.Value = true
game:GetService("ReplicatedStorage").VirusUI:Clone().Parent = infectedPlr.PlayerGui
if game:GetService("ReplicatedStorage").VirusUI:Clone().Parent == infectedPlr.PlayerGui then
print("Player Has been infected")
end
end
end
end)

3 comments
did the error occur at line 5 or 6, the output should say
You have maybe forget a "end" for your if not, because I don't see it here
There is no EOF exception. You may be using a Server-sided script, therefore, the LocalPlayer pointer won't refer to a Client affiliated Player Object.