I've been looking for the answer to this for a while. I tried a few of the answers I've seen on here, but since I'm a beginner at scripting, I can't figure out how to make it work.

This is the most recent one I've tried:

Main Script in Workspace

	local Players = game:GetService("Players")
	local PlayerDiedChatEvent = game:GetService('ReplicatedStorage'):WaitForChild('PlayerDiedChatEvent')
	 
	local function PlayerJoined(Player)
	    Player.CharacterAdded:Connect(function(character)
	        local Humanoid = character:WaitForChild("Humanoid")
	        if Humanoid then
	            Humanoid.Died:Connect(function()
	                PlayerDiedChatEvent:FireAllClients(Player)
	            end)
	        end
	    end)
	end
	 
	Players.PlayerAdded:Connect(function(Player)
	    PlayerJoined( Player )
	end)
	 
	for _, Player in pairs(Players:GetPlayers()) do
	    PlayerJoined(Player)
	end

Local Script in Starter Character Scripts

	local PlayerDiedChatEvent = game:GetService('ReplicatedStorage'):WaitForChild('PlayerDiedChatEvent')
	 
	PlayerDiedChatEvent.OnClientEvent:Connect(function(PlayerWhoDied)
	    print (PlayerWhoDied, 'just kicked the can')
	end)

It would help me a lot if you could tell me what to put and where to put it.

1 comment

0

Like in Lab Experiment if that helps.