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

What is the missing argument - or is there a nill argument? in this code?

There seems to be a "argument 1 missing or nil on line 8" please may someone point it out :P

goku

local id = 3352345245 -- not the real id :P
local part = script.Parent


script.Parent.Touched:Connect(function(pepe)
	if game.Players:GetPlayerFromCharacter(pepe.Parent) then
		local player = game.Players.LocalPlayer
		if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player,id) then
			part.CanCollide = false 
			wait(0.5)
			part.CanCollide = true
			
		end
	
	end

	
end)

1 answer

✓ Accepted answer

The reason why is because the first argument is nil, probably because you're not using a client-sided script. UserOwnsGamePassAsync's first argument needs the first argument as an int64 representing a player's userId.

Try this in a server-sided(normal) script:

local id = 3352345245
local part = script.Parent


script.Parent.Touched:Connect(function(pepe)
    if game.Players:GetPlayerFromCharacter(pepe.Parent) then
        local player = game.Players:GetPlayerFromCharacter(pepe.Parent)
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id) then
            part.CanCollide = false 
            wait(0.5)
            part.CanCollide = true

        end

    end


end)

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