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

How come this script won't give the player 10000 cash? [SOLVED]

Asked by
Agios 10
9 years ago

So, I'm using Berezaa's tycoon kit, and it saves the money inside of serverstorage. I wrote this script to try to give +10000 cash if the player has the gamepass, but it won't do anything.

(And yes, I do have the ID defined, it's just in the very first part of the script)

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)

        if game:GetService("GamePassserivce"):PlayerHasPass(player, id) then
            local swag = game.ServerStorage.MoneyStorage.Player.Value
            swag = swag + 10000
        end
    end)
end)

0
On line 5 you used Player with a capital P but in line one the functions argument is player with a lower case p Mystdar 352 — 9y

1 answer

Log in to vote
0
Answered by
Discern 1007 Moderation Voter
9 years ago

Your error is on line 6. The variable "swag" is saved as the value's data, not the actual value itself. You need to make "swag" the value instance instead of its data. This means you must use swag.Value every time you want to change it. I understand it's a pain, but it's how things must be done.

Check this out:

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)

        if game:GetService("GamePassserivce"):PlayerHasPass(player, id) then
            local swag = game.ServerStorage.MoneyStorage.Player
            swag.Value = swag.Value + 10000
        end
    end)
end)
Ad

Answer this question