Can anyone fix in full script?
KillsForBadge=5
KillsFor2Badge=15
BadgeID=39056832
Badge2ID=39095658
function onHumanoidDied(humanoid,player)
local killer=getKillerOfHumanoidIfStillInGame(humanoid)
if killer~=nil then
local kills=killer:findFirstChild("Kills")
if killer~=player then
kills.Value=kills.Value+1
if kills.Value==KillsForBadge then
local b=game:GetService("BadgeService")
if b~=nil then
b:AwardBadge(killer.userId,BadgeID)
end
local m=Instance.new("Message")
m.Name="Achievment"
m.Text="Achievment: "..tostring(KillsForBadge).." Kills"
m.Parent=killer
delay(7,function()
if m~=nil then
m:remove()
end
end)
end
else
--kills.Value=kills.Value-1
end
end
end
function onHumanoidDied(humanoid,player)
local killer=getKillerOfHumanoidIfStillInGame(humanoid)
if killer~=nil then
local kills=killer:findFirstChild("Kills")
if killer~=player then
kills.Value=kills.Value+1
if kills.Value==KillsForBadge then
local b=game:GetService("BadgeService")
if b~=nil then
b:AwardBadge(killer.userId,Badge2ID)
end
local m=Instance.new("Message")
m.Name="Achievment"
m.Text="Achievment: "..tostring(KillsFor2Badge).." Kills"
m.Parent=killer
delay(7,function()
if m~=nil then
m:remove()
end
end)
end
else
--kills.Value=kills.Value-1
end
end
end
function onPlayerRespawn(property,player)
if property=="Character" and player.Character~=nil then
local humanoid=player.Character.Humanoid
humanoid.Died:connect(function() onHumanoidDied(humanoid,player) 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 onPlayerEntered(newPlayer)
local kills=Instance.new("IntValue")
kills.Name="Kills"
kills.Value = 0
kills.Parent = newPlayer
local money = Instance.new("IntValue")
money.Name = "Money"
money.Value = 0
money.Parent = newPlayer
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)
end
game.Players.ChildAdded:connect(onPlayerEntered) |