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

Changing a players data value when they kill another player?

Asked by 5 years ago

Right now I am struggling with detecting if a player kills another and if so giving them money per that kill. So this is my current KO script and what I have to give the killer more value in that data.value

local function PlayerWhomstDied(PlayerKilled)
    local humanoid = PlayerKilled.Character["Humanoid"]
    local tag = humanoid:findFirstChild("creator")
    if tag then 
        if tag.Value.Name == PlayerKilled.Name then 
            print("Dont kill yourself :(")
        else
            print(tag.Value.Name.. " oof-ed you up good ha gottem")
            local killer = tag.Value.Name
            killer.Folder.DATA2.Value = killer.Folder.DATA2.Value + 1
        end
    else
        print("Creator not found :(")
        PlayerKilled.Folder.DATA3.Value = PlayerKilled.Folder.DATA3.Value + 1

    end
end
game.Players.PlayerAdded:connect(function(Player)
    Player.CharacterAdded:connect(function(c)
        local hum = c:WaitForChild("Humanoid")
        hum.Died:connect(function() 
            PlayerWhomstDied(Player) 
        end)
    end)
end)

Oh and the red error i get whenever trying to give myself the plus 1 DATA2.Value would be " ServerScriptService.KO:11:attemkpt to index field 'Folder' (a nil value) " I do understand its something on the 11th line with reaching the folder that holds my data values but I dont know what :^(

Any help would be appericated!

0
Are you sure that the Folder exist? AIphanium 124 — 5y
0
I also found a problem, killer is the TAG's value, you cannot put a Folder inside a value. AIphanium 124 — 5y
0
The folder does exist and I see what your'e saying about the tagged value. When im home im going to try a fix I thought of thoughout the day so ill get back to you if it works or doesnt :) RNApoint 0 — 5y
0
I forgot how I planned on doing this but Ill try to remember it but I was thinking if I could save just the tagged's value to a variable I could use that to get to game.Players.(Variable With just Their Name).Folder.DATA2.Value but I'm not sure of how to basically extract only the name in order to get to the DATA folder :^( RNApoint 0 — 5y
0
I forgot how I planned on doing this but Ill try to remember it but I was thinking if I could save just the tagged's value to a variable I could use that to get to game.Players.(Variable With just Their Name).Folder.DATA2.Value but I'm not sure of how to basically extract only the name in order to get to the DATA folder :^( Ill try to remember what I had planned though kek RNApoint 0 — 5y

Answer this question