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!
if putmapsinworkspace == true then local map = Maps:FindFirstChild(mapnamethatwaspicked) map.Parent = MapFolder elseif game.Workspace:FindFirstChild(mapnamethatwaspicked) or MapFolder:FindFirstChild(mapnamethatwaspicked) then MapFound = true -- This would not work, because you have never sat putmapsinworkspace to = true, its always false...
end
Just to let you all know the error is at line 71 to line 73. The error is 'Argument 1 Missing Or Nil'. Those lines are the ones that are meant to teleport the player to some bricks in the map named: 'Spawnpoint1', 'Spawnpoint2', 'Spawnpoint3' and 'Spawnpoint4'. Also, some people are saying: 'This would not work, because you have never sat putmapsinworkspace to = true, its always false...'. It is false due to that there is only one map and there is no point in putting it in MapsFolder over and over again, it's pointless! So it is already in the folder - That's why its putmapsinworkspace = false! Now let me get to the last point, people are also saying that the players variable = nil! Its set to nil because it will set it to the players name when the round starts. (As seen on line 56 - 69). Also for some reason, the status is not changing (value and text)? Script in status text gui:
script.Parent.Text = game.ServerStorage.Status.Value game.ServerStorage.Status.Changed:Connect(function() script.Parent.Text = game.ServerStorage.Status.Value end)
Thank you for reading, Chris.