#Argument 1 missing or nil when running a task.defer

1 messages · Page 1 of 1 (latest)

velvet willow
#
    print(playername)
    if playermagcheck(playername) then
        print("blah")
        rig_clone:Destroy()
    else
        wait(0.1)
        task.spawn(looper)
    end
end

function playermagcheck(name)
    if (game.Workspace:FindFirstChild(name).HumanoidRootPart.Position - script.Parent.Parent.HumanoidRootPart.Position).Magnitude > 25 then
        return true
    else
        return false        
    end
end

function speak(player)

    rig_clone:PivotTo(rig_clone:GetPivot() * CFrame.Angles(0, math.rad(0), 0))
    rig_clone.Parent = player.PlayerGui.Dialog.ViewportFrame
    rig_clone:PivotTo(CFrame.new(80.81, 9.301, -27.594))
    local rotation = CFrame.Angles(0, math.rad(60), 0)
    local modelCFrame = rig_clone:GetPivot()
    rig_clone:PivotTo(modelCFrame * rotation)
    print(rig_clone.Parent.Name)
    local rootPosition = npc.Position + Vector3.new(0, HEIGHT_OFFSET, 0)
    local cameraPosition = Vector3.new(rootPosition.X, rootPosition.Y, CAMERA_DEPTH)
    ui_shell = player.PlayerGui.Dialog
    local cam = ui_shell.Camera 
    local headPos = rig_clone.Head.Position + Vector3.new(0, HEIGHT_OFFSET, 0)
    local camPos = headPos + Vector3.new(0, 0, CAMERA_DEPTH)
    cam.CFrame = CFrame.new(cameraPosition, headPos)
    ui_shell.Enabled = true
    task.defer(looper,player.name)
end``` Here is the parts having an issue, it's saying that even though I am passing an arguement, I am so confused...
#

I am trying to run a loop to tell how far the player is from the npc in a co routine but it's not really letting me pass arguments

crude fiber
#

Don't know what task.defer does but if you can tell me what the parameters are ment to be I might be able to help

#

Nvm I searched it's purpose

#

Should it not me task.defer(looper(player.nzme))

#

Name*

#

Be*

#

Christ I hate mobile

velvet willow
#

I thought you had to pass the arguments like task.defer(looper,args) because it's a seperate perameter within the docs

south apexBOT
#

studio** You are now Level 3! **studio

velvet willow
#

I'll try it rq

#

Nope

#

It knows the user name but refuses to use it

crude fiber
#

Try print it under function playermagcheck

#

Print the name

velvet willow
#

got it

#

so it runs once?

#

OH

#

shoot

#

I got it

#

I pass the args once but not again

#

Fixed it

#

I passed the args once but never again in the loop

crude fiber
#

Oh I see