Username shows up as the person, but not the dead person

So, whenever I kill anyone, my name appears on my screen and their name appears on their screen. The problem is, I haven’t died in the game but my name still appears.

Here’s the 2 scripts:
Server-Sided Script:

local TweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(3)

local tableOfPhrases = {" got fried!", " got dundendun did brodda"," watched an among us animation video", " literally exploded"}
local remote = game:GetService("ReplicatedStorage"):WaitForChild("DeathAnnounceEvent")

game:GetService("Players").PlayerAdded:Connect(function(Player)
	local DeathT = Player.PlayerGui:WaitForChild("DeathAnnounce").Death
	local tween = TweenService:Create(DeathT,tweenInfo,{["BackgroundTransparency"] = 0, ["TextTransparency"] = 0})
	local tween2 = TweenService:Create(DeathT,tweenInfo,{["BackgroundTransparency"] = 1, ["TextTransparency"] = 1})
	Player.CharacterAdded:Connect(function(Character)
		Character:WaitForChild("Humanoid").Died:Connect(function()
			remote:FireAllClients()
			if Character:WaitForChild("Humanoid").Health >=1 then
				
				return 
				
			end
		end)
	end)
end)

Client-sided Script:

local remote  = game:GetService("ReplicatedStorage"):WaitForChild('DeathAnnounceEvent')

local Player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local tweenInfo = TweenInfo.new(3)
local char = Player.Character or Player.CharacterAdded:Wait()
local TweenService = game:GetService("TweenService")
local DeathT = Player.PlayerGui:WaitForChild("DeathAnnounce").Death
local tween = TweenService:Create(DeathT,tweenInfo,{["BackgroundTransparency"] = 0, ["TextTransparency"] = 0})
local tween2 = TweenService:Create(DeathT,tweenInfo,{["BackgroundTransparency"] = 1, ["TextTransparency"] = 1})
local tableOfPhrases = {" got fried!", " got dundendun did brodda"," watched an among us animation video", " literally exploded"}
remote.OnClientEvent:Connect(function()

	tween:Play()
	local randNumber = math.random(1,#tableOfPhrases)
	DeathT.Text = Player.Name .. tableOfPhrases[randNumber]

	task.wait(2.5)

	tween2:Play()
	print("@" .. Player.DisplayName .. " has fallen!")

	
end)

Any help is appreciated! Have a nice day/night.

1 Like

In the client script, you are putting Player.Name in the DeathT.Text, and for each player, Player.Name will be their own name. I recommend when firing the event from the server do …

remote:FireAllClients(Player.Name)

… and change the client script to adapt to this passed name.

remote.OnClientEvent:Connect(function(deadName)

	tween:Play()
	local randNumber = math.random(1,#tableOfPhrases)
	DeathT.Text = deadName.. tableOfPhrases[randNumber]

	task.wait(2.5)

	tween2:Play()
	print("@" .. deadName.. " has fallen!")

	
end)

Thank you, that helped very much.

1 Like

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