Hi, I wanted to make a script where it destroys certain objects inside a player's character when they die but I can't seem to figure it out.

Here's my script:

game.Players.PlayerAdded:Connect(function(blr)
	blr.CharacterAdded:Connect(function(jar)
		jar:WaitForChild("Humanoid").Died:Connect(function()
			if jar:FindFirstChildOfClass("Humanoid"):FindFirstChild("CanBeSeen") and jar:FindFirstChild("seen") then 
				jar:FindFirstChildOfClass("Humanoid"):FindFirstChild("CanBeSeen"):Destroy()
				jar:FindFirstChild("seen"):Destroy()
			end
		end)
		kenactive(jar)
		print(blr.Name)
	end)
end)

and yes, I did some searching and found out that you can't use playeradded in a localscript so I tried childadded and it still didn't work.

2 comments

0

why is there just a random if on line 4

0

its part of line 5 & 6. idk why he decided to put it in a separate line.