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

While in Studio/Game, :PlayerHasPass not working for me, why?

Asked by
JellyYn 70
6 years ago

While in studio making my game, I made a script to purchases a Speed Coil. The PromptPurchase works fine in the game and in studio, but when it checks if the player has it, it doesn't clone to the player's Backpack or StarterGear.

local player = game.Players.LocalPlayer
local id = 1480411563 -- my gamepass id for the speed coil

script.Parent.MouseButton1Down:connect(function()
    game:GetService("MarketplaceService"):PromptPurchase(player, id) --asks to buy
end)

game.Players.PlayerAdded:Connect(function()
    if game:GetService("GamePassService"):PlayerHasPass(player, id) then
        game.ServerStorage.SpeedCoil:Clone().Parent = player.Backpack, player.StarterGear 
        --clones the coil to the players inventory ^ (it should, but doesn't work)
        print(player.Name.. " has gamepass!")
    end
end)    

Yes, I did just add the comments to tell you what does what for further help.

I also get a message saying 21:19:33.996 - AssetId '1480411563' is of type Game Pass. Please use GamePassService:PlayerHasPass instead.

If anyone could tell me how to fix it so when you do have the game pass, it gives you the coil?

Please and thank you ~ JellyDevelops/JellyYn

Answer this question