local Gamepass = 122313
local Player = game.Players.LocalPlayer
function onTouched(m) p = m.Parent:findFirstChild("Humanoid") if p ~= nil and game.MarketplaceService:PlayerOwnsAsset(Player,Gamepass) then game.ServerStorage.Ask:Clone(game.Players.LocalPlayer.PlayerGui) end end script.Parent.OnServerEvent:connect(onTouched)
-- if anyone doesen't know gp means gamepass
You can't use PlayerOwnsAsset()
on a game pass id. You would need to use it on its asset id.
Each game pass has its gamepass id which can be used with GamepassService
and an asset id, like every other roblox asset, which can be used with MarketplaceService:PlayerOwnsAsset()
So you should either use your gamepass's asset id which you can obtain using this api, like so:
(btw you should make this a server script in order to be able to access ServerStorage
and not use LocalPlayer
, and I corrected your Clone()
usage)
local gamePassAssetId = 199286259 function onTouched(m) local plr = m.Parent.ClassName == "Model" and game:GetService("Players"):GetPlayerFromCharacter(m.Parent) if plr and game:GetService("MarketplaceService"):PlayerOwnsAsset(plr, gamePassAssetId) then game:GetService("ServerStorage").Ask:Clone().Parent = plr.PlayerGui end end script.Parent.OnServerEvent:connect(onTouched)
Or use its gamepass id, like this:
local gamePassId = 122313 function onTouched(m) local plr = m.Parent.ClassName == "Model" and game:GetService("Players"):GetPlayerFromCharacter(m.Parent) if plr and game:GetService("GamePassService"):PlayerHasPass(plr, gamePassId) then game:GetService("ServerStorage").Ask:Clone().Parent = plr.PlayerGui end end script.Parent.OnServerEvent:connect(onTouched)