I’m having a nightmare about this script and I can’t fix it what so ever. It keeps sending out messages like “you won against name” and"you lost against name" even when they tie… Is there any reason to why this happens?
local Players = game:GetService("Players")
local Event = game:GetService("ReplicatedStorage"):FindFirstChild("Events"):FindFirstChild("PLAYER_KILLED_PLAYER")
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
if Humanoid then
local h = Instance.new("StringValue")
h.Name = "creator"
h.Parent = Humanoid
Humanoid.Died:Connect(function()
if game:GetService("CollectionService"):HasTag(Player, "Starter Pack") then
game:GetService("ServerStorage"):FindFirstChild("Death Effect"):Clone().Parent = Character:FindFirstChild("HumanoidRootPart") or Character:WaitForChild("HumanoidRootPart")
end
wait(1)
local Stats = Player:FindFirstChild("leaderstats")
if Stats then
local Reset_Killstreak = Stats:FindFirstChild("Killstreak")
if Reset_Killstreak then
Reset_Killstreak.Value = 0
local Folder = game:GetService("ServerScriptService"):FindFirstChild("DataStore")
local Deaths = Folder[Player.Name]:FindFirstChild("Total Deaths")
if Deaths then
Deaths.Value = Deaths.Value + 1
local Tag = Humanoid:FindFirstChild("creator")
if Tag then
local Killer = Players:FindFirstChild(Tag.Value)
if Killer then
local Check_Killer = Killer.Character:FindFirstChildOfClass("Humanoid")
print("Killer:", Check_Killer.Health)
if Check_Killer.Health < 2 then
return
end
Event:FireClient(Player, Killer.Name, Killer.TeamColor, "DEFEATED")
Event:FireClient(Killer, Player.Name, Player.TeamColor, "KILLED")
local Killer_Stats = Killer:FindFirstChild("leaderstats")
if Killer_Stats then
local Killer_Wins = Killer_Stats:FindFirstChild("Wins")
if Killer_Wins then
Killer_Wins.Value = Killer_Wins.Value + 1
local Wins = Folder[Tag.Value]:FindFirstChild("Total Wins")
if Wins then
Wins.Value = Wins.Value + 1
local Killstreak = Killer_Stats:FindFirstChild("Killstreak")
if Killstreak then
Killstreak.Value = Killstreak.Value + 1
local Killstreak_Folder = Folder[Tag.Value]:FindFirstChild("Best Killstreak")
if Killstreak_Folder then
if Killstreak.Value < Killstreak_Folder.Value then
Killstreak_Folder.Value = Killstreak_Folder.Value + 1
else
Killstreak_Folder.Value = Killstreak.Value
end
end
end
end
end
end
end
end
end
end
end
end)
end
end)
end)