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

I'm completely baffled at this and I have no clue why this isn't working. (Why doesn't this work?)

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

So, my KO/WO script has mysteriously stopped working, and I don't recall (not just recall, I've reverted and grabbed the previous script, and it still doesn't work.) changing anything except removing a "Spree" value, and adjusted the script accordingly. I have no clue why this isn't working, and I don't even know how I can fix it. I've used my previous script, which failed, I just rewrote it, which failed.

It should also be noted that when you reset, the Death value will increase by one, and when you kill with the correct weapons, the kill value will increase by one.

The relevant scripting:

    local pc = player.Character
    local function died()
        d.Value = d.Value + 1
        local t = pc:FindFirstChild("Tag")
        if t then
            for i,v in pairs(game.Players:GetPlayers()) do
                if v.Name == t.Value then
                    v.leaderstats.Kills.Value = v.leaderstats.Kills.Value + 1
                end
            end
        end
    end
    pc.Humanoid.Died:connect(died) -- It used to be pc.Humanoid.Died:connect(function() instead of ---what it is now.

The above is what I believe to be the only relevant code, whoever, if I am mistaken, here is the full script.

game.Players.PlayerAdded:connect(function(player)
    repeat
        wait()
    until player and player.leaderstats and player.Character.Humanoid
    local l = player:FindFirstChild("leaderstats")

    local k = Instance.new("IntValue",l)
    k.Name = "Kills"
    k.Value = 0

    local d = Instance.new("IntValue",l)
    d.Name = "Deaths"
    d.Value = 0

    local pc = player.Character
    local function died()
        d.Value = d.Value + 1
        local t = pc:FindFirstChild("Tag")
        if t then
            for i,v in pairs(game.Players:GetPlayers()) do
                if v.Name == t.Value then
                    v.leaderstats.Kills.Value = v.leaderstats.Kills.Value + 1
                end
            end
        end
    end
    pc.Humanoid.Died:connect(died)
end)

--[[
    local t = Instance.new("StringValue", humanoid.Parent)
    t.Name = "Tag"
    t.Value = player.Name
    coroutine.resume(coroutine.create(function()
    wait(1)
    t:remove()
    end))
--]]

Finally, I know I'm using a StringValue. It's worked for me up until now. That, and I really have no idea how to use ObjectValue too well, and when I made the switch, the script either failed to work, or did the same as what it's doing now as far as I can remember.

Any help and replies will be ****extremely**** appreciated.

0
Well, this isn't an answer, but it's a tip, you can shorten the tagger from having a whole coroutine to just a single line. You just simply add an item to the Debris Service like this: game.Debris:AddItem(t, AMOUNT_OF_TIME_HERE) lightpower26 399 — 8y
0
Alright. I never thought of that. Thanks. But any guesses as to why something so simple ceases to work? MINEBLOX106 55 — 8y
0
Does this work online? Or is there only a problem in studio? BlueTaslem 18071 — 8y
0
It doesn't work in Studio either. So I know it's not the script type. MINEBLOX106 55 — 8y
0
Just for my own validation, this script should work right? MINEBLOX106 55 — 8y

Answer this question