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

Help on the killfeed system error? [closed]

Asked by 6 years ago

So, basically every time I test this kill-feed script the output throws me this: https://ibb.co/nAgsW8 I checked the script and there are no errors.

how can I fix it?

Here's the code: (sorry, it's a lot)

Victim = "" -- The person who died
Killer = "" -- The person who killed the victim
kf = nil -- The gui

function update() -- Updates the System
    player = game.Players:GetChildren() -- Requires players in server

    for i = 1, #player do -- repeats until all players. then returns
        kf = player[i].PlayerGui.KillFeed -- Sets "up" as the killfeed in the player gui
        kf1 = kf.kf1
        kf2 = kf.kf2
        kf3 = kf.kf3
        kf4 = kf.kf4
        kf5 = kf.kf5
        kf1.Text = kf2.Text
        kf2.Text = kf3.Text
        kf3.Text = kf4.Text
        kf4.Text = kf5.Text
        kf5.Text = "" ..Killer.. " killed: " ..Victim.. ""
    end

    kf = game.StarterGui.Update
    kf1 = kf.kf1
    kf2 = kf.kf2
    kf3 = kf.kf3
    kf4 = kf.kf4
    kf5 = kf.kf5
    kf1.Text = kf2.Text
    kf2.Text = kf3.Text
    kf3.Text = kf4.Text
    kf4.Text = kf5.Text
    kf5.Text = "" ..Killer.. " killed: " ..Victim.. ""
end

function onPlayerEntered(newPlayer)
    -- Stats data

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

    local Humanoid = newPlayer.Character.Humanoid -- Get Humanoid
    Humanoid.Died:connect(function()
        onHumanoidDied(humanoid, newPlayer) -- Executes on humanoid died (main script)
    end)

    newPlayer.Changed:connect(function(property)
         onPlayerRespawn(property, newPlayer) -- Executes respawn function
    end)


end

function Send_Death_Event(victim, killer)
    local KillerName = game.Players.LocalPlayer
    -- Sets the killer to the player because the killed themself
    if killer ~= nil then KillerName = KillerName.Name end
    print("Death event: ", victim.Name, " KILLED by ", KillerName)
    Victim = victim.Name -- Set's the victim
    Killer = KillerName -- Set's the killer

    update() -- Updates the system

    if shared["deaths"] ~= nil then
        shared["deaths"](victim, killer)
        print("SENT DB DEATH EVENT") -- Sends the event
    end
end

function Send_DB_Event_Kill(killer, victim) 
    print("KILL EVENT. ", killer.Name, " BLOXXED ", victim.Name)

    if shared["kills"] ~= nil then
        shared["kills"](killer, victim)
        print("SENT DB KILL EVENT")
    end 
end

function onHumanoidDied(humanoid, player)
    -- remove spree in stat
    -- -1 score

    local killer = getKillerOfHumanoidIfStillInGame(humanoid) -- Get the killer in game
    Send_Death_Event(player, killer) -- Sends death event
    handleKillCount(humanoid, player) -- Handles the kill count
end

function onPlayerRespawn(property, player)
    if property == "Character" and player.Character ~= nil then
        local humanoid = player.Character.Humanoid -- Get Humanoid
        local p = player -- Player
        local h = humanoid -- Find the humanoid

        humanoid.Died:connect(function()
             onHumanoidDied(h, p) -- Runs the event
        end) 
    end
end

function getKillerOfHumanoidIfStillInGame(humanoid) 
    local tag = humanoid:findFirstChild("creator") -- Finds the 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
            -- Sets the score up by 2
            -- Sets the spree up by 1
        else
            -- Sets the score down by 1
            -- Sets the spree to 0
        end
        Send_DB_Event_Kill(killer, player) 
    end
end

game.Players.ChildAdded:connect(onPlayerEntered) -- OnPlayer enter
0
Don't come on this site with free model code, expecting for it to be fixed. User#19524 175 — 6y

Closed as Not Constructive by User#19524

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?