Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

when i run my game in roblox studio, Argument 1 missing or nil shows in the output. Any help?

This error shows in the output pls help:

09:53:01.135 Argument 1 missing or nil - Client - LocalScript:1 09:53:01.136 Stack Begin - Studio 09:53:01.136 Script 'Players.N0TaLaN.PlayerGui.LobbyGui.Deploy.LocalScript', Line 1 - Studio - LocalScript:1 09:53:01.136 Stack End - Studio

Local Script:

local randomMap = game.Workspace.Folder:WaitForChild() local spawns = randomMap.Spawns:GetChildren() local plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function() for i = 1, #plr do local randomSpawn = spawns[math.random(1, #spawns)] plr[i].Character.HumanoidRootPart.CFrame = CFrame.new(randomSpawn.Position) end end)

2 answers

WaitForChild() -- it is now waiting for nil (nothing) you need to type something you wanna wait for so if you are waiting for Part inside Folder then type 

game.Workspace.Folder:WaitForChild("Part")

Okey, then you can try this

local plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function() 
	if game.Workspace.Folder:WaitForChild() then -- this will check it after you clicked

local spawns = randomMap.Spawns:GetChildren() 

for i = 1, #plr do 
local randomSpawn = spawns[math.random(1, #spawns)] 

plr[i].Character.HumanoidRootPart.CFrame = CFrame.new(randomSpawn.Position) 
end 
	end)

5 comments

0

oh

0

now its saying this, any fixes?: 10:24:35.703 Infinite yield possible on 'Workspace.Folder:WaitForChild("Shipment by N0TaLaN")' - Studio 10:24:35.703 Stack Begin - Studio 10:24:35.703 Script 'Players.N0TaLaN.PlayerGui.LobbyGui.Deploy.LocalScript', Line 1 - Studio - LocalScript:1 10:24:35.704 Stack End - Studio 10:24:48.654 Players.N0TaLaN.PlayerGui.LobbyGui.Deploy.LocalScript

0

do you really have "Shipment by N0TaLaN" inside that folder?

0

no its in server stoage but it clones itself from another script inti the folder

0

btw for loop will loop only once because game.Players.LocalPlayer is 1 player

You might want to add a time-out. For example:

Local Script:

local randomMap = game.Workspace.Folder:WaitForChild("Part", 15) --This is how long the script is going to wait for the Instance to load in the game.

local spawns = randomMap.Spawns:GetChildren() 
local plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	 for i = 1, #plr do 
		local randomSpawn = spawns[math.random(1, #spawns)] 
		plr[i].Character.HumanoidRootPart.CFrame = CFrame.new(randomSpawn.Position) 
	end 
end)

--By the way, if you don't want the players to spawn at the same spawns, try this 

local randomMap = game.Workspace.Folder:WaitForChild("Part", 15) 

local spawns = randomMap.Spawns:GetChildren() 
local plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	 for i = 1, #plr do 
		if plr.Character then 
			plr[i].Character.HumanoidRootPart.CFrame = spawns[1].CFrame
			table.remove(spawns, 1)
		end 
	end 
end)

Hope this helped a little!

1 comment

0

Just saw this and this is a local script so you need a remote event to teleport the players when they click the Gui and a server script to teleport the players.

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