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 nil argument?

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

###Server Scripts

A Server Script (Script) is, implied by it's name, run on the Server. When FilteringEnabled is on (which it is 24/7 now), the Server is restricted in some natures. An example of this is the server's access to LocalPlayer.

When used in a server script, LocalPlayer will always return nil. This is why you are erroring, but fear not. We can use the Hit parameter of the Touched event to get the player!

#####Small Note

UserOwnsGamePassAsync takes a player's userid, not the player themselves.

###Solution

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:GetPlayerFromCharacter(pepe.Parent)
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id) then
            part.CanCollide = false 
            wait(0.5)
            part.CanCollide = true

        end

    end


end)

1 comment

0

Hurrah! it works - thanks for the quick awnser aswell(i aspire to become half the scriptier yah are :P)

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