Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.