I'm making a murder game and I have an error. 'Argument 1 Missing Or Nil' The error part is at the part where it teleports them to the map. I am an experienced Roblox scripter but I have never seen this error. If any of you know this error or know a fix please reply below with the fix. Hope you can help me with this!
Script:
local knife = game.ServerStorage:WaitForChild('Knife')
local gun = game.ServerStorage:WaitForChild('Revolver')
local status = game.ServerStorage:WaitForChild('Status').Value
local plrsneeded = 1
local stopgame = false
local gameon = false
local mapnames = {'Combat League By Parasc'}
local putmapsinworkspace = false
local Maps = game.ServerStorage:WaitForChild('Maps')
local MapFolder = game.Workspace:WaitForChild('Map')
local MapFound = false
local player1 = nil
local player2 = nil
local player3 = nil
local player4 = nil
local ranks = {'Murderer','Sheriff'}
local murderer = false
local sheriff = false
function RoundOver()
game.SoundService.RoundOver:Play()
status = 'Round Over!'
wait(5)
gameon = false
end
while true do
if stopgame == false and gameon == false then
gameon = true
MapFound = false
murderer = false
sheriff = false
player1 = nil
player2 = nil
player3 = nil
player4 = nil
status = 'Intermission'
wait(35)
status = 'Picking Map'
local mapnamethatwaspicked = mapnames[math.random(1, #mapnames)]
wait(4)
status = 'Map Picked: '..mapnamethatwaspicked
if putmapsinworkspace == true then
local map = Maps:FindFirstChild(mapnamethatwaspicked)
map.Parent = MapFolder
elseif game.Workspace:FindFirstChild(mapnamethatwaspicked) or MapFolder:FindFirstChild(mapnamethatwaspicked) then
MapFound = true
end
wait(3)
if MapFound == true then
status = 'Starting Round'
game.SoundService.RoundStart:Play()
wait(3)
game.SoundService.RoundStart:Stop()
game.SoundService.RoundStart:Play()
wait(2.5)
for i,v in pairs(game.Players:GetChildren()) do
local rank = ranks[math.random(1, #ranks)]
if rank == 'Murderer' and murderer == false then
player1 = v.Name
murderer = true
knife:Clone().Parent = v.Backpack
elseif rank == 'Sheriff' and sheriff == false then
player2 = v.Name
sheriff = true
gun:Clone().Parent = v.Backpack
else
player3 = v.Name
end
end
--Heres the error \/
game.Workspace:FindFirstChild(player1).HumanoidRootPart.CFrame = CFrame.new(Vector3.new(MapFolder[mapnamethatwaspicked].Spawnpoint1.Position.Vector3))
game.Workspace:FindFirstChild(player2).HumanoidRootPart.CFrame = CFrame.new(Vector3.new(MapFolder[mapnamethatwaspicked].Spawnpoint2.Position.Vector3))
game.Workspace:FindFirstChild(player3).HumanoidRootPart.CFrame = CFrame.new(Vector3.new(MapFolder[mapnamethatwaspicked].Spawnpoint3.Position.Vector3))
--Error /\
wait(60)
game.Players:FindFirstChild(player1).Character.Humanoid.Health = 0
game.Players:FindFirstChild(player2).Character.Humanoid.Health = 0
game.Players:FindFirstChild(player3).Character.Humanoid.Health = 0
RoundOver()
else
status = 'Failed to load map. (MAP NOT FOUND IN WORKSPACE)'
end
end
end
game.Players.Changed:Connect(function()
if game.Players.NumPlayers == not plrsneeded then
stopgame = true
status = 'Not Enough Players (4 Needed) Or Round Just Ended'
else
stopgame = false
end
end)
Thank you for reading, ChrisThrRoblox1234 (Chris) P.S. I would like this to be fixed quickly if possible!

4 comments
You should short your code and show scripters where the error is or telling us on what line is error. You have to get the line of error in output.
FindFirstChild(player1) when player1 is nil...maybe you mean FindFirstChild("Player1")? I don't really know, but that's the error anyway
NumPlayers is deprecated.
Guys this is now resolved!