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

Why won't this gamepass script give money?

Asked by
Agios 10
9 years ago

I'm using Berezaas tycoon kit, and it stores the money inside of

ServerStorage V MoneyStorage V Player (numvalue) and then the Value property in Player

Here's the code (yes the gamepass id is defined, its just in the script earlier)

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function()
local swag = game.ServerStorage.MoneyStorage:FindFirstChild("player.Name")      
if game:GetService("GamePassService"):PlayerHasPass(player.userId, id) then
swag.Value = swag.Value + 2500
end end) end)

1 answer

Log in to vote
1
Answered by 9 years ago

You are searching ServerStorage for something named "Player.Name" and not the players name. Also there is no reason to use FindFirstChild if you are not going to check if the object exists.

Also note that you are giving the player money every time he respawns. Which could be abused.

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function()
        local swag = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)      
        if game:GetService("GamePassService"):PlayerHasPass(player.userId, id) and swag then
            swag.Value = swag.Value + 2500
        end 
    end)
end)

Ad

Answer this question