So like the Title says I’m making a Kill Feed and its working and all, but the only problem is that there is a chance that the Script detects the Player dying 3 times.
And in conclusion it will give you 3 kills, 3x coins and 3 messages that you have killed someone.
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
character.Humanoid.Died:connect(function()
if character.Humanoid:FindFirstChild("creator") then
local creator = character.Humanoid:FindFirstChild("creator")
--add coins to killer
game.Players:FindFirstChild(creator.Value.Name):FindFirstChild("Currency").Coins.Value = game.Players:FindFirstChild(creator.Value.Name):FindFirstChild("Currency").Coins.Value + 2
--add kill
game.Players:FindFirstChild(creator.Value.Name):FindFirstChild("leaderstats").Kills.Value = game.Players:FindFirstChild(creator.Value.Name):FindFirstChild("leaderstats").Kills.Value + 1
--add death
player:FindFirstChild("leaderstats").Deaths.Value = player:FindFirstChild("leaderstats").Deaths.Value + 1
--Say that you gained coins
local coin = script.TextLabel2:Clone()
coin.Text = "+2 Coins"
coin.Parent = game.Players:FindFirstChild(creator.Value.Name).PlayerGui.CoinFeed.KillFeedFrame
game:GetService("Debris"):AddItem(coin,6)
--Tell Players That Someone Died
for _, players in pairs(game.Players:GetPlayers()) do
if players.PlayerGui then
local kill = script.TextLabel:Clone()
kill.Text = creator.Value.Name.." Killed "..player.Name
kill.Parent = players.PlayerGui.KillFeed.KillFeedFrame
game:GetService("Debris"):AddItem(kill,6)
end
end
end
end)
end)
end)