My aim here is when a player touches another player, they become infected. The problem here is that I have no idea how to make it so only players can infect others. So, it means that whenever the hitbox is touched by even the player’s own character, it infects them.
game.Players.PlayerAdded:Connect(function(player)
local infected = Instance.new("BoolValue")
infected.Value = false
infected.Parent = player
infected.Name = "Infected"
player.CharacterAdded:Connect(function(char)
char.HumanoidRootPart.Hitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and not player.Infected.Value then
hit.Parent["Body Colors"]:Destroy()
game.ReplicatedStorage.ZombieBody:Clone().Parent = hit.Parent
hit.Parent.Head.face:Destroy()
game.ReplicatedStorage.ZombieFace:Clone().Parent = hit.Parent.Head
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
game.ReplicatedStorage.Infect:FireClient(player)
player.PlayerGui["008Alert"].Enabled = true
player.Infected.Value = true
end
end)
end)
end)
All help is appreciated! <3