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

Gamepass does not work Backpack is not a valid member of Player? [Answared By Myself]

local id = 455098424
 
game.Players.PlayerAdded:connect(function(player)
    if Game:GetService("GamePassService"):PlayerHasPass(player, id) then 
        print(player.Name .. " doesn't have the game pass...")
		else		
		game.ReplicatedStorage.Rotorcycle:Clone().Parent = game.Players.LocalPlayer.Backpack
		game.ReplicatedStorage.Rotorcycle:Clone().Parent = game.Players.LocalPlayer.StarterGear
		print(player.Name .. " has the game pass!")           
end
end)

Backpack is not a valid member of Player

1 answer

✓ Accepted answer

Try this code:

local id = 455098424

game.Players.PlayerAdded:connect(function(player)
    if game:GetService("GamePassService"):PlayerHasPass(player, id) then 
        print(player.Name .. " doesn't have the game pass...")
        else        
        game.ReplicatedStorage.Rotorcycle:Clone().Parent = game.Players.LocalPlayer:WaitForChild("Backpack")
        game.ReplicatedStorage.Rotorcycle:Clone().Parent = game.Players.LocalPlayer:WaitForChild("StarterGear")
        print(player.Name .. " has the game pass!")           
end
end)

Your script is running the INSTANT somebody joins a game, and sometimes it will not have created the player's Backpack yet.

2 comments

0

works in studio but not in game:/

0

fixed it self! with a litle help from another question

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