Find the Mistake

Yes I am trying to do whenever someone dies his/her name will appear but Error is Workspace.Script:3: Expected ‘(’, ‘{’ or , got ‘Char’

game.Players.PlayerAdded:Connect(function(player)
	local Char = player.Character or player.CharacterAdded:Wait  
		Char.Humanoid.Died:Connect(function()
			print(player.Name .. " has died!")
		end)
	end)

You forgot to add parenthesis after ‘Wait’.

Here’s edited code:

game.Players.PlayerAdded:Connect(function(player)
	local Char = player.Character or player.CharacterAdded:Wait()  
		Char.Humanoid.Died:Connect(function()
			print(player.Name .. " has died!")
		end)
	end)

This should work.

3 Likes