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

output says "Gamepasses isn't a valid member of player"?

So I made a server script that made a new folder called "Gamepasses" and inside the folder is a boolvalue named "BlueFire" and is set to false

what I want to do with the gamepass is set that value to true

local id = 9736269

game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
	if purchased and id == ido then
		plr.Gamepasses.BlueFire.Value = true
	end
end)

game.Players.PlayerAdded:Connect(function(plr)
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,id) then
		game.Players:WaitForChild(plr.Name).Gamepasses.BlueFire.Value = true
	end
end)

It was working fine but then I added datastore2 and some reason it doesn't work idk y.

2 comments

0

I'm not sure why you are adding datastores for gamepass you just need to out an if statement for if the player owns the gamepass

0

I didn't add a datastore for gamepass, I added a data store for a money value and I didn't change the gamepass code AT ALL. Idk why its doing this

1 answer

✓ Accepted answer

Try something like this

local Lighting = game:GetService("Lighting")
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gamepassId = 8900287 --Put the ID of the asset here


local function onPlayerAdded(player)
    local function onCharacterAdded(character)
        if MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamepassId) then
            
					player.Gamepasses.BlueFire.Value = true
				
				
				
				
				end   
                

				
            end
      

    if player.Character then
        onCharacterAdded(player.Character)
    end
    player.CharacterAdded:Connect(onCharacterAdded)
end

Players.PlayerAdded:Connect(onPlayerAdded)

3 comments

0

it still doesn't work it just says "Gamepasses is not a valid member of Player". This is the script I did to add the BlueFire bool value. local gp = Instance.new("Folder", plr) gp.Name = "Gamepasses" local bFire = Instance.new("BoolValue", gp) bFire.Name = "BlueFire" bFire.Value = false

1

nvm I got it now I just needed WaitForChild on the gamepass. thanks for helping me tho

0

np

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