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

I am making this game and a script in my game is encountering errors, How do I fix this? [closed]

Asked by 6 years ago

So, I was just trying to make a kill for money script for my game, I keep on encountering errors whenever I try using the code that I provided.

Here is the code I used

game.Players.PlayerAdded:connect(function(player)
    local folder = Instance.new("Folder",player)
    folder.Name = "leaderstats"
    local currency1 = Instance.new("IntValue",folder)
    currency1.name = "Cash"
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()
            local tag = character.Humanoid:FindFirstChild("creator")
            if tag ~= nil then
                if tag.Value ~= nil then
                    local stats = tag.Value:WaitForChild("leaderstats")
                    stats["Cash"].Value = stats["Cash"].Value + 10
                end
            end
        end)
    end)
end)

Whenever I try killing an NPC or person, it just doesn't work. Can someone please help me?

0
You didn’t capitalize “Name” on line 5. Also I recommend you use :Connect and not :connect as I heard it was deprecated. User#20279 0 — 6y
0
Denny is correct. It would also help if you could put down what errors the script is encountering. That'd help us resolve the problem. Troidit 253 — 6y
0
I tried the script and it works fine as long as you correct what Denny said. Other than that it must be your sword/gun/whatever you have that isn't creating a tag. KamikazeShard 23 — 6y
0
Thanks Denny9876! Automat_io 0 — 6y
0
No problem! :D User#20279 0 — 6y

Locked by cabbler and minikitkat

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?