.Touched event not working when rig is cloned

When I clone an npc from ReplicatedStorage through a remote event, the .Touched event does not work. Everything is spelled correctly and the damage script seems to work fine when I don’t clone it and it doesn’t work in Roblox Player. The following script works and the script is inside the cloned npc when I check it.

Damage Script:

local plr = game.Players.PlayerAdded:Wait()


local db = false




script.Parent:WaitForChild("Humanoid").Touched:Connect(function(hit)
	if hit.Parent:FindFirstChildWhichIsA("Humanoid") and hit.Parent.Name == plr.Character.Name then
		if db == false then
			db = true
			
			hit.Parent.Humanoid:TakeDamage(50)
			wait(1)
			db = false

		end
	end
end)


and when I put put print(“fheiohgoi”) before the humanoid part nothing pops up and there are no errors in output. pls help me

1 Like

I think it is because of the game.Players.PlayerAdded:Wait()

So this is in an npc?
Is this a sever script running on the server?

What is this script supposed to do?
Why do you need to get the plr value?

1 Like

Thank you this helped me realize something now it’s working

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.