#Why do my characters not load into the map?

11 messages · Page 1 of 1 (latest)

autumn inlet
#

Hello, I tried to follow Alvin Blox, how to make a fighting game but my players did not spawn into the map. I could not add anymore. But if you need it, I can dm it to you!

-- Define variables

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Serverrstorage = game:GetService("ServerStorage")
local MapsFolder = Serverrstorage:WaitForChild("Maps")
local Status = ReplicatedStorage:WaitForChild("Status")
local GameLength = 300
local reward = 1

-- Game Loop

while true do

Status.Value = "Waiting for enough players"

repeat wait(1) until game.PLayers.NumPlayers >= 2

Status.Value = "Intermission"

wait(15)

local plrs = {}

for i, player in pairs(game.Players:GetPlayers()) do
    if player then
        table.insert(plrs,player) -- Add each player into plrs table
    end
end

wait(2)

local AvailableMaps = MapsFolder:GetChildren()

local ChosenMap = AvailableMaps [math.random(1,#AvailableMaps)]

Status.Value = ChosenMap.Name.." Chosen"

local ClonedMap = ChosenMap:Clone()
ClonedMap.Parent = workspace

-- Teleports players to the map

local SpawnPoints = ClonedMap:FindFirstChild("SpawnPoints")

if not SpawnPoints then
    print("Spawnpoints not found!")
end

local AvailableSpawnPoints = SpawnPoints:GetChildren()

for i, player in pairs(plrs) do
    if player then
        character = player.Character
        if character then
            -- Teleport them
            
            character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[1]
            table.remove(AvailableSpawnPoints,1)
hearty locust
#

game.PLayers.NumPlayers >= 2 syntax error

gilded raptorBOT
#

studio** You are now Level 5! **studio

hearty locust
#

AvailableMaps [math.random(1,#AvailableMaps)] syntax error again

#

you do know u can see if ur script has an error if u look here

#
-- Define variables

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Serverrstorage = game:GetService("ServerStorage")
task.wait(2)
local MapsFolder = Serverrstorage:WaitForChild("Maps")
local Status = ReplicatedStorage:WaitForChild("Status")
local GameLength = 300
local reward = 1

-- Game Loop

while true do

    Status.Value = "Waiting for enough players"

    repeat wait(1) until game.Players.NumPlayers >= 2

    Status.Value = "Intermission"

    wait(15)

    local plrs = {}

    for i, player in pairs(game.Players:GetPlayers()) do
        if player then
            table.insert(plrs,player) -- Add each player into plrs table
        end
    end

    wait(2)

    local AvailableMaps = MapsFolder:GetChildren()

    local ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)]

    Status.Value = ChosenMap.Name .. " Chosen"

    local ClonedMap = ChosenMap:Clone()
    ClonedMap.Parent = workspace

    -- Teleports players to the map

    local SpawnPoints = ClonedMap:FindFirstChild("SpawnPoints")

    if not SpawnPoints then
        print("Spawnpoints not found!")
    end

    local AvailableSpawnPoints = SpawnPoints:GetChildren()

    for i, player in pairs(plrs) do
        if player then
            character = player.Character
            if character then
                -- Teleport them

                character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[1]
                table.remove(AvailableSpawnPoints,1)
            end
        end
    end
end

fixed it up a bit but it seems like there's an infinite wait for the maps folder

autumn inlet