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

Double Coins Gamepass script not working?

My 2x gamepass isn't working?

game.Players.PlayerAdded:Connect(function(plr)
plr:WaitForChild("leaderstats"):WaitForChild("Potatoes").Changed:Connect(function()
	if game.MarketplaceService:PlayerOwnsAsset(plr,IDHERE) then
			plr.leaderstats.Potatoes.Value = plr.leaderstats.Potatoes.Value + 1
		end
	end)
end)

I didn't put my ID in but where it says ID here is my gamepass ID

3 answers

After the game pass id system was reformed, this function became valid only for legacy game passes, which did not utilise the new ids. This is also said in the wiki page:

This method should not be used for game passes, since they use a separate ID system.

Instead, you should be using the MarketplaceServics:UserOwnsGamePassAsync() function to check for ownership of newer game passes.

1 comment

0

I have done that, but now the function fires to many times, because after it changes it, it fires again, and again, forever

@ankurbohra04

local MS = game:GetService("MarketplaceService")
local VIPID = 8110615

local RS = game:GetService("ReplicatedStorage")

game.Players.PlayerAdded:Connect(function(plr)
	if MS:UserOwnsGamePassAsync(plr.UserId,VIPID) then
		
		plr:WaitForChild("leaderstats"):WaitForChild("Potatoes").Changed:Connect(function()
			plr.leaderstats.Potatoes.Value = plr.leaderstats.Potatoes.Value + 1
		end)
	end
end)

2 comments

0

This works? Is potatoes supposed to be a multiplier?

0

this doesn't work, potatoes is an IntValue inside of leaderstats, sorry for the formatting

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