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

Missing argument? Can someone help?

Asked by 10 years ago

I was testing this script and on the Output is saying there's a missing argument, here's what it says:

23:07:05.802 - Argument 1 missing or nil 23:07:05.803 - Script 'Players.Player1.PlayerGui.ScreenGui.TextButton.LocalScript', Line 9 - global Down 23:07:05.803 - Script 'Players.Player1.PlayerGui.ScreenGui.TextButton.LocalScript', Line 26

Here's the script:

plr = game.Players.LocalPlayer
a = plr.Up.Value

function Down()
    for i,v in pairs(game.Workspace:GetChildren()) do
            if v.Name == "SpawnLocation" then
                vv = {v.Name}
                d = vv[math.random(1,#vv)]
                plr.Character.Humanoid:MoveTo(d.Position)
                a = false
            end
    end
end

function Up()
    for i,v in pairs(game.Workspace.Lobby:GetChildren()) do
        if v.Name == "SpawnLocationU" then
            vv = {v.Name}
            d = vv[math.random(1,#vv)]
                plr.Character.Humanoid:MoveTo(d.Position)
        end
    end
end
script.Parent.MouseButton1Down:connect(function()
    if a == true then
        Down()
    elseif a == false then
        Up()
    end
end)

1 answer

Log in to vote
-2
Answered by 10 years ago

You could try this:

replace the for loops with this

ch = game.Workspace:GetChildren()
for i = 1, #ch do
    if ch[i].Name == "SpawnLocation" then
        d = ch[(math.random(1,#ch))]
        plr.Character.Humanoid:MoveTo(d.Position)
        a = false
    end
end

If it gives you any errors then please post them.

0
Doesn't work. Pawsability 65 — 10y
0
That makes no sense at all... Shawnyg 4330 — 10y
0
You don't have to lower my reputation if it doesn't work you little no for good shroom. PixelAspect 0 — 10y
Ad

Answer this question