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

Need Scripting help on roblox! -Murder game issues with teleporting players to map-?

Asked by 6 years ago

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!

0
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. AswormeDorijan111 531 — 6y
0
FindFirstChild(player1) when player1 is nil...maybe you mean FindFirstChild("Player1")? I don't really know, but that's the error anyway Vulkarin 581 — 6y
0
NumPlayers is deprecated. User#19524 175 — 6y
0
Guys this is now resolved! ChrisThrRoblox1234 12 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago
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
0
Actually its set to false because there is only currently 1 map (which is already in workspace so there is no need to do that.) ChrisThrRoblox1234 12 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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.

0
The Status isn't changing the text because you put the Status in ServerStorage, which the Client can't access. Put the Status in ReplicatedStorage saSlol2436 716 — 6y
0
By the way, looking at an image, your script in your TextLabel should be a LocalScript saSlol2436 716 — 6y

Answer this question