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

Someone tell me what's wrong with this script ? speaks argument 1 nil or missing

Asked by 2 years ago

so I created this script today, right, a car spawn in a surfacegui, only gamepass the car but when I go to test it says Argument 1 nil or missing tell me what's wrong in the script.

script.Parent.MouseButton1Click:Connect(Function(Player)
if game:GetService("GamepassService"):PlayerHasPass(Player, 21318770) then
local Car = game.ServerStorage.Car
local Clone = Car:Clone()
clone.Parent = workspace
clone.MakeJoints()
else
game:getService("MarketPlaceService"):PromptPurchase(Player, 21318770)
script.parent.Image = "rbxassetid://600802277"

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

If I'm not mistaken, the second parameter of the function PlayerHasPass requires the AssetID when using GamepassService. Since MarketplaceService has superseded GamepassService and all of its features have been deprecated because they only function with older assets, I do not advise utilizing it.

Here's a version of the script using MarketplaceService. Learn more about MarketplaceService.

local player = game.Players.LocalPlayer
local mps = game:GetService("MarketplaceService")
local gamepassID = 123456

if mps:UserOwnsGamePassAsync(player.UserId, gamepassID) then
    -- whatever u want here
else
    mps:PromptGamePassPurchase(player, gamepassID)
end
Ad

Answer this question