Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do make it so on each kill, I get +1 kill on leaderboard?

Asked by
Xyternal 247 Moderation Voter
2 years ago
Edited 2 years ago

I'm editing the entire question: So I found this creator tutorial, but I have no idea where to put the script. Do i put it somewhere here?

if skp_0 then
        if skp_0.Team ~= SKP_0.Team or skp_0.Neutral then
            local skp_t = Instance.new("ObjectValue")
            skp_t.Name  = "creator"
            skp_t.Value = SKP_0
            skp_t.Parent= SKP_1
            game.Debris:AddItem(skp_t, 1)

            SKP_1:TakeDamage(skp_1)
            return;
        end;

        if not gameRules.TeamKill then return; end;
        local skp_t = Instance.new("ObjectValue")
        skp_t.Name  = "creator"
        skp_t.Value = SKP_0
        skp_t.Parent= SKP_1
        game.Debris:AddItem(skp_t, 1)

        SKP_1:TakeDamage(skp_1 * gameRules.TeamDmgMult)
        return;
    end

    local skp_t = Instance.new("ObjectValue")
    skp_t.Name  = "creator"
    skp_t.Value = SKP_0
    skp_t.Parent= SKP_1
    game.Debris:AddItem(skp_t, 1)

    SKP_1:TakeDamage(skp_1)
    return;
end

or here?

function UpdateLog(Player,humanoid)

    local tag = humanoid:findFirstChild("creator")

    if tag ~= nil then

        local hours = os.date("*t")["hour"]
        local mins = os.date("*t")["min"]
        local sec = os.date("*t")["sec"]
        local TagType = tag:findFirstChild("type")

        if tag.Value.Name == Player.Name then
            local String = Player.Name.." Died | "..hours..":"..mins..":"..sec
            table.insert(CombatLog,String)
        else
            local String = tag.Value.Name.." Killed "..Player.Name.." | "..hours..":"..mins..":"..sec
            table.insert(CombatLog,String)
        end

        if #CombatLog > 50 then
            Backup = Backup + 1
            warn("ACS: Cleaning Combat Log | Backup: "..Backup)
            warn(CombatLog)
            CombatLog = {}
        end
    end
end

2 answers

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

You can use creator tags

this might help https://devforum.roblox.com/t/how-to-use-creator-tag/1728641

0
blocked Xyternal 247 — 2y
0
and i can't find anything on google, so if you don't mind, can you tell me what exactly i have to do? Xyternal 247 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

Make a script in ServerScriptService, and when a player died, it will check if it has a creator tag inside its Humanoid. And if it does, it will add kills to the player who killed them.

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
   Player.CharacterAdded:Connect(function(Character)
      local Humanoid = Character:WaitForChild("Humanoid")

      Humanoid.Died:Connect(function()
         local Tag = Humanoid:FindFirstChild("creator")

         if Tag and Tag:IsA("ObjectValue") and Tag.Value then
            local otherPlayer = Tag.Value
            local otherLeaderstats = otherPlayer:WaitForChild("leaderstats")

            otherLeaderstats:WaitForChild("Kills").Value += 1
         end
      end)
   end)
end)
0
sry to say, it doesn't work :/ Xyternal 247 — 2y
0
but i tested it on npc so that might mean something? Xyternal 247 — 2y
0
and im using r6 models Xyternal 247 — 2y
0
oh, this only works for real players, not npcs. do u want me to also make a scropt for npcs too? T3_MasterGamer 2189 — 2y
0
also do you have a leaderstats folder in the player? T3_MasterGamer 2189 — 2y

Answer this question