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

when i use the function and i don't own gp it still does it anyone have a fix?

Asked by
danglt 185
6 years ago

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

1 answer

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

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)
Ad

Answer this question