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

Trying to add a gamepass script, argument 2 is missing or nil?

Asked by 5 years ago
Edited 5 years ago
local gamepass = 5620181
local service = game:GetService("MarketplaceService")

script.Parent.MouseButton1Click:connect(function()
    if service:PlayerOwnsAsset(gamepass) then
        if script.Parent.Parent.Parent.TeleportGui.Enabled == false then
            script.Parent.Parent.Parent.TeleportGui.Enabled = true
        else
            script.Parent.Parent.Parent.TeleportGui.Enabled = false
        end
    end
end)

It's supposed to open a gui if the player owns the gamepass.

EDIT: Figured out that a few things had been changed. There's now no error whatsoever, but nothing happens when clicking the button

Here's the new script:

local passid = 5620181
local service = game:GetService("MarketplaceService")

script.Parent.MouseButton1Click:connect(function()
    if service:UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, passid) then
        if script.Parent.Parent.Parent.TeleportGui.Enabled == false then
            script.Parent.Parent.Parent.TeleportGui.Enabled = true
        else
            script.Parent.Parent.Parent.TeleportGui.Enabled = false
        end
    end
end)

1 answer

Log in to vote
0
Answered by 5 years ago

Use a localscript and this script instead:


local gamepass = 5620181 local service = game:GetService("MarketplaceService") script.Parent.MouseButton1Click:connect(function() if service:PlayerOwnsAsset(game.Players.LocalPlayer,gamepass) then if script.Parent.Parent.Parent.TeleportGui.Enabled == false then script.Parent.Parent.Parent.TeleportGui.Enabled = true else script.Parent.Parent.Parent.TeleportGui.Enabled = false end end end)
0
Hmm... I don't get the error anymore, but now nothing happens. sebse456 13 — 5y
0
Try changing the fourth line with " if service:PlayerOwnsAsset(game.Players.LocalPlayer.UserId,gamepass) then " or User#24960 0 — 5y
0
or this if service:PlayerOwnsAsset(game.Players.LocalPlayer,gamepass) == true then User#24960 0 — 5y
Ad

Answer this question