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

[Solved]Why is the delay function erroring when it has two arguments?

Asked by 5 years ago
Edited 5 years ago

I have a function that I want delayed for two seconds but it is erroring in a really weird way. I think it might be the fact that it is a module script that contains the function but I will post the scripts and see what you have to say. The error states: the delay function requires two arguments. Here is the code that requires the module script and delays the function:

local runDropperFunction = require(serverStorage.ModuleScripts.RunDropper)
delay(2, runDropperFunction(copy))

Here is what is inside the module script:

local function runDropper(dropper)

    local debris = game:GetService("Debris")

    spawn(function()

        local loopWaitTime = dropper:WaitForChild("LoopWaitTime")
        local oreValue = dropper:WaitForChild("OreValue")
        local dropperPart = dropper:WaitForChild("DropperPart")

        if loopWaitTime and oreValue and dropperPart then

            local waitTime = loopWaitTime.Value
            local oreToClone = Instance.new("Part")

            while true do 

                wait(waitTime)

                local newOre = oreToClone:Clone()

                newOre.Name = "Ore"
                newOre.Parent = dropper
                newOre.Size = Vector3.new(1, 1, 1)
                newOre.Position = dropperPart.Position

                debris:AddItem(newOre, 20)

                local cash = Instance.new("NumberValue")

                cash.Name = "Cash"
                cash.Parent = newOre
                cash.Value = oreValue.Value

            end 
        end
    end)
end

return runDropper

Hope you guys can help. Thanks!

Answer this question