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

What is the Missing argument or nil argument?

Asked by 5 years ago

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

Log in to vote
0
Answered by
green271 635 Moderation Voter
5 years ago

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)
0
Hurrah! it works - thanks for the quick awnser aswell(i aspire to become half the scriptier yah are :P) ScriptingNubs 55 — 5y
Ad

Answer this question