Hello! I have a Shop GUI that checks to see if the player owns the game pass, if so spawns the gear the player selected or prompts them to buy the game pass and shows an error GUI label. At first I had it in a normal script it worked fine in Studio but in game I get the error below.
MarketplaceService:PlayerOwnsAsset() player should be of type Player, but is of type nil
Then I realized that I needed to put it in a Local Script. When I did that It still works fine in studio but still does not work in game and now no message appears at all in server log.
Any help would be appreciated.
My Code (in a local script):
-- Made by WindNT
local passId = 485342977 -- change this to your game pass ID.
local tool = game.ServerStorage.SparkleTime
local plr = game.Players.LocalPlayer
function isAuthenticated(player) -- checks to see if the player owns your pass
return game:GetService("MarketplaceService"):PlayerOwnsAsset(plr, passId)
end
script.Parent.MouseButton1Click:connect(function(player)
if isAuthenticated(plr) then --Has Game Pass
tool:Clone().Parent = plr.Backpack
print(plr.Name .. " has bought the game pass with id " .. passId)
else -- If not then Show error and prompt purchase
--script.Parent.ClickDetector.MouseClick:connect(function(player) -- Prompt purchase
game:GetService("MarketplaceService"):PromptPurchase(plr, passId)
--end)
--GUI MESSAGE
--Clear GUI Message
script.Parent.Parent.ErrorMessage.Visible = true
wait(.2)
script.Parent.Parent.ErrorMessage.Visible = false
wait(.2)
script.Parent.Parent.ErrorMessage.Visible = true
wait(.2)
script.Parent.Parent.ErrorMessage.Visible = false
wait(.2)
script.Parent.Parent.ErrorMessage.Visible = true
wait(8)
script.Parent.Parent.ErrorMessage.Visible = false
end
end)

1 comment
Thanks for your help, I ended up figuring out the issue. I had my tools is Server Storage not Lighting.