Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

[URGENT] Change Leaderstats Value if Gamepass Not Working? (Infinite Bag)

So Im trying to create an infinite bag just like simulators have, and if a player own a gamepass, then change the value of "Pack" to infinite or 99999999999999 or something, it doesnt work and im not sure why, could anybody help me here, It is quite urgent. Here is my script

local id = 7746555
local player = game.Players.LocalPlayer

game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
    if purchased and ido == id then
		wait (1)
          player:WaitForChild("leaderstats").Pack.Value = 999999999
        end
    end)

game.Players.PlayerAdded:Connect(function(plr)
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,id) then
           wait (1)
 			player:WaitForChild("leaderstats").Pack.Value = 999999999
        end
    end)

The script a ServerScript and is located in the ServerScriptService

3 comments

0

Try replacing all "player"s with "plr"

0

You can't use a local script to change the leaderstats if your game is FE

0

^ games are "filtering enabled" whether the actual setting is enabled or not, so the term FE is not really valid anymore. Everything should be defined as Server-Client

2 answers

✓ Accepted answer
local id = 7549271--The id of the gamepass
game.Players.PlayerAdded:Connect(function(player)--Connects to the PlayerAdded event.
    plr.CharacterAdded:connect(function(char)--Connects to the CharacterAdded event.
                   if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id) then--Checks if the player has the GamePass
wait (1)
          player:WaitForChild("leaderstats").Pack.Value = math.huge
        end
    end)
end)

Hello, PurpleProgram!

As I can see from game.Players.LocalPlayer this is a local script, but MarketPlaceService can only be used by the server(in most cases).

Basically you need to convert that LocalScript to a Script

ServerScript:

local id = 7746555

local MarketPlaceService = game:GetService("MarketplaceService") -- Use Variables to make code easier to read

MarketPlaceService.PromptGamePassPurchaseFinished:Connect(function(player,ido,purchased)
	if purchased and ido == id then
		wait (1)
		player:WaitForChild("leaderstats").Pack.Value = 9e9 -- 9e9 is the biggest possible number
	end
end)

game.Players.PlayerAdded:Connect(function(player)
	if MarketPlaceService:UserOwnsGamePassAsync(player.UserId,id) then
		wait (1)
		player:WaitForChild("leaderstats").Pack.Value = 9e9  -- 9e9 is the biggest possible number
	end
end)

Hope this helps

If you need any more help, message me on roblox or post a comment here =D

2 comments

0

even better, if it is an infinite value that they want then the theoretical float point limit "math.huge" can be used

0

Yep, use math.huge instead of 9e9, since this code "print(9e9 > math.huge)" will return false.

This discussion is preserved as it was. New answers, comments, and votes are closed.