How to make a You Killed Gui (Can Someone Fix my script?)

hey so I’m trying to Make a You killed GUI But it didn’t Actually Work, i made the Model so if somebody Can Fix it i Would Really Appreciated Player Killed Gui (broken ;<) - Roblox

1 Like

Could u paste the code here? ignore

sure
this is the MainLeaderstats Script


stands = {}
CTF_mode = false

function onHumanoidDied(humanoid, player)
	local stats = player:findFirstChild("leaderstats")
	if stats ~= nil then
		local deaths = stats:findFirstChild("Deaths")
		local spree = stats:findFirstChild("Kill Streak")
		deaths.Value = deaths.Value + 1
		spree.Value = 0

		local killer = getKillerOfHumanoidIfStillInGame(humanoid)

		handleKillCount(humanoid, player)
	end
end

function onPlayerRespawn(property, player)


	if property == "Character" and player.Character ~= nil then
		local humanoid = player.Character.Humanoid
		local p = player
		local h = humanoid
		humanoid.Died:connect(function() onHumanoidDied(h, p) end )
	end
end

function getKillerOfHumanoidIfStillInGame(humanoid)

	local tag = humanoid:findFirstChild("creator")


	if tag ~= nil then

		local killer = tag.Value
		if killer.Parent ~= nil then 
			return killer
		end
	end

	return nil
end

function handleKillCount(humanoid, player)
	local killer = getKillerOfHumanoidIfStillInGame(humanoid)
	if killer ~= nil then
		local stats = killer:findFirstChild("leaderstats")
		if stats ~= nil then
			local kills = stats:findFirstChild("Kills")
			local spree = stats:findFirstChild("Kill Streak")
			local plr = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
			local char = plr.Character or plr.CharacterAdded:Wait()
			if killer ~= player then
				kills.Value = kills.Value + 1
				game:GetService("ReplicatedStorage").DisplayPlayersName:FireClient(killer)
				game:GetService("ReplicatedStorage").PlayersNameValue.Value = player.Humanoid:FindFirstChild("creator").Value.Name
				
				spree.Value = spree.Value + 1
			else
				kills.Value = kills.Value - 1

			end
		end
	end
end


-----------------------------------------------



function findAllFlagStands(root)
	local c = root:children()
	for i=1,#c do
		if (c[i].className == "Model" or c[i].className == "Part") then
			findAllFlagStands(c[i])
		end
		if (c[i].className == "FlagStand") then
			table.insert(stands, c[i])
		end
	end
end

function hookUpListeners()
	for i=1,#stands do
		stands[i].FlagCaptured:connect(onCaptureScored)
	end
end

function onPlayerEntered(newPlayer)

	if CTF_mode == true then

		local stats = Instance.new("Folder")
		stats.Name = "leaderstats"

		local captures = Instance.new("IntValue")
		captures.Name = "Captures"
		captures.Value = 0


		captures.Parent = stats


		while true do
			if newPlayer.Character ~= nil then break end
			wait(5)
		end

		stats.Parent = newPlayer

	else

		local stats = Instance.new("Folder")
		stats.Name = "leaderstats"

		local kills = Instance.new("IntValue")
		kills.Name = "Kills"
		kills.Value = 0

		local deaths = Instance.new("IntValue")
		deaths.Name = "Deaths"
		deaths.Value = 0

		local spree = Instance.new("IntValue")
		spree.Name = "Kill Streak"
		spree.Value = 0

		kills.Parent = stats
		deaths.Parent = stats
		spree.Parent = stats

		while true do
			if newPlayer.Character ~= nil then break end
			wait(5)
		end

		local humanoid = newPlayer.Character.Humanoid

		humanoid.Died:connect(function() onHumanoidDied(humanoid, newPlayer) end )

		newPlayer.Changed:connect(function(property) onPlayerRespawn(property, newPlayer) end )
		
		stats.Parent = newPlayer

	end

end


function onCaptureScored(player)

	local ls = player:findFirstChild("leaderstats")
	if ls == nil then return end
	local caps = ls:findFirstChild("Captures")
	if caps == nil then return end
	caps.Value = caps.Value + 1

end

findAllFlagStands(game.Workspace)
hookUpListeners()
if (#stands > 0) then CTF_mode = true end
game.Players.ChildAdded:connect(onPlayerEntered)



and this is the KillPlayers LocalScript

game.ReplicatedStorage.DisplayPlayersName.OnClientEvent:Connect(function()
	script.Parent.PlayerKilled.Visible = true
	script.Parent.PlayerKilled.Playername.Text = game.ReplicatedStorage.PlayersNameValue.Value
	wait(3)
	script.Parent.PlayerKilled.Visible = false
end)

and this is the stuff
image

for your local script you are passing the value through a value in RepStorage. this means the value is replicated to all players. if you do connect(params) you can pass the value directly to the player.

2 Likes
local ReplicatedStorage = game:GetService("ReplicatedStorage");
local TweenService = game:GetService("TweenService");

local function Display()
	if (not script.Parent.Visible) then
		script.Parent.Visible = true;
		wait(5);
		script.Parent.Visible = false;
	end
end

ReplicatedStorage.DisplayKill.OnClientEvent:Connect(Display);
1 Like

um it just makes the frame visible, and then invisible

BaseplateKillGuiTest1.rbxl (35.8 KB)
Works for me

i meant to make a gui that shows the players name that you killed

Did you check this post? You killed gui help - #9 by MiniYear

1 Like

You forgot to put the model on-sale by the way.

game.ReplicatedStorage.DisplayPlayersName.OnClientEvent:Connect(function()
	script.Parent.PlayerKilled.Visible = true
	script.Parent.PlayerKilled.Playername.Text = game.ReplicatedStorage.PlayersNameValue.Value
	wait(3)
	script.Parent.PlayerKilled.Visible = false
end)

Where is the param for the killer value u r sending thru the re?

Honestly i dont understand wt ur doing in this script, unless im dumb it literally sends back the player who got killed the killer. I might try to send a better version of the script.

1 Like

Could you explain how the plr gets killed?

Check if the target humanoid is dead on the .Touched event on the weapon you kill the enemy. Then send it to the client through a remote event. Then do the job.

so if the player kills another player the script will detect the players death, and the player that killed the other player will get a kill point
this is the script its a leaderstat Script


stands = {}
CTF_mode = false

function onHumanoidDied(humanoid, player)
	local stats = player:findFirstChild("leaderstats")
	if stats ~= nil then
		local deaths = stats:findFirstChild("Deaths")
		local spree = stats:findFirstChild("Kill Streak")
		game:GetService("ReplicatedStorage").DisplayDeath:FireClient(player)
		deaths.Value = deaths.Value + 1
		spree.Value = 0

		local killer = getKillerOfHumanoidIfStillInGame(humanoid)

		handleKillCount(humanoid, player)
	end
end

function onPlayerRespawn(property, player)


	if property == "Character" and player.Character ~= nil then
		local humanoid = player.Character.Humanoid
		local p = player
		local h = humanoid
		humanoid.Died:connect(function() onHumanoidDied(h, p) end )
	end
end

function getKillerOfHumanoidIfStillInGame(humanoid)

	local tag = humanoid:findFirstChild("creator")


	if tag ~= nil then

		local killer = tag.Value
		if killer.Parent ~= nil then 
			return killer
		end
	end

	return nil
end

function handleKillCount(humanoid, player)
	local killer = getKillerOfHumanoidIfStillInGame(humanoid)
	if killer ~= nil then
		local stats = killer:findFirstChild("leaderstats")
		if stats ~= nil then
			local kills = stats:findFirstChild("Kills")
			local spree = stats:findFirstChild("Kill Streak")
			if killer ~= player then
				kills.Value = kills.Value + 1
				game:GetService("ReplicatedStorage").DisplayKill:FireClient(killer)
				spree.Value = spree.Value + 1
			else
				kills.Value = kills.Value - 1

			end
		end
	end
end


-----------------------------------------------



function findAllFlagStands(root)
	local c = root:children()
	for i=1,#c do
		if (c[i].className == "Model" or c[i].className == "Part") then
			findAllFlagStands(c[i])
		end
		if (c[i].className == "FlagStand") then
			table.insert(stands, c[i])
		end
	end
end

function hookUpListeners()
	for i=1,#stands do
		stands[i].FlagCaptured:connect(onCaptureScored)
	end
end

function onPlayerEntered(newPlayer)

	if CTF_mode == true then

		local stats = Instance.new("Folder")
		stats.Name = "leaderstats"

		local captures = Instance.new("IntValue")
		captures.Name = "Captures"
		captures.Value = 0


		captures.Parent = stats


		while true do
			if newPlayer.Character ~= nil then break end
			wait(5)
		end

		stats.Parent = newPlayer

	else

		local stats = Instance.new("Folder")
		stats.Name = "leaderstats"

		local kills = Instance.new("IntValue")
		kills.Name = "Kills"
		kills.Value = 0

		local deaths = Instance.new("IntValue")
		deaths.Name = "Deaths"
		deaths.Value = 0

		local spree = Instance.new("IntValue")
		spree.Name = "Kill Streak"
		spree.Value = 0

		kills.Parent = stats
		deaths.Parent = stats
		spree.Parent = stats

		while true do
			if newPlayer.Character ~= nil then break end
			wait(5)
		end

		local humanoid = newPlayer.Character.Humanoid

		humanoid.Died:connect(function() onHumanoidDied(humanoid, newPlayer) end )

		newPlayer.Changed:connect(function(property) onPlayerRespawn(property, newPlayer) end )
		
		stats.Parent = newPlayer

	end

end


function onCaptureScored(player)

	local ls = player:findFirstChild("leaderstats")
	if ls == nil then return end
	local caps = ls:findFirstChild("Captures")
	if caps == nil then return end
	caps.Value = caps.Value + 1

end

findAllFlagStands(game.Workspace)
hookUpListeners()
if (#stands > 0) then CTF_mode = true end
game.Players.ChildAdded:connect(onPlayerEntered)



hope it makes sense

Im askinh How the plr gets killed, like thru guns or swords or smth.

oh, i guess through guns though…