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

My players aren't teleporting to my game map?

Asked by 3 years ago

I am following an online scripting tutorial from Alvin_Blox and even though i followed his code exactly my players wont teleport to the game map like his. Everything works fine until this point. For reference check out "how to make a roblox game" by Alvin_Blox on youtube. Specifically video #3. Also here is my code for reference:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local ServerStorage = game:GetService("ServerStorage")

local MapsFolder = ServerStorage:WaitForChild("MapsFolder")

local Status = ReplicatedStorage:WaitForChild("Status")

local GameLength = 50

local Reward = 25

while true do Status.Value = "Waiting for enough players!" repeat wait(1) until game.Players.NumPlayers >= 1 Status.Value = "Intermission"

wait(10)

local plrs = {}

for i, player in pairs(game.Players:GetPlayers()) do
    if player then
        table.insert(plrs,player)
    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 = game.Workspace

local SpawnPoints = ClonedMap:GetFirstChild("SpawnPoints")

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

local AvailableSpawnPoints = SpawnPoints:GetChildren()

--["Spawnpoinit","Spawnpoinit","Spawnpoinit","Spawnpoinit","Spawnpoinit","Spawnpoinit","Spawnpoinit","Spawnpoinit","Spawnpoinit",]

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

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

            local Sword = ServerStorage.Sword:Clone()
            Sword.Parent = game.Workspace.StartPack

            local GameTag = Instance.new("BoolValue")
            GameTag.Name = "GameTag"
            GameTag.Parent = player.Character
        else
            if not player then
                table.remove(plrs,i)
            end
        end
    end
end

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

I believe that in line 30 you wrote:


local AvailableSpawnPoints = SpawnPoints:GetChildren() --["Spawnpoinit","Spawnpoinit","Spawnpoinit","Spawnpoinit","Spawnpoinit","Spawnpoinit","Spawnpoinit","

You do not need to do this as the spawnpoints are already defined in SpawnPoints:GetChildren() This gets all the spawnpoints in the model.

local AvailableSpawnPoints = SpawnPoints:GetChildren("SpawnPoint") [[--This gets all the parts in the model named SpawnPoint--]]

Also in line 21 you wrote "GetFirstChild" which is not a function. It is "FindFirstChild"

wait(10)

local plrs = {}

for i, player in pairs(game.Players:GetPlayers()) do
    if player then
        table.insert(plrs,player)
    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 = game.Workspace

local SpawnPoints = ClonedMap:FindFirstChild("SpawnPoints") -- FindFirstChild

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

local AvailableSpawnPoints = SpawnPoints:GetChildren()

--["Spawnpoinit","Spawnpoinit","Spawnpoinit","Spawnpoinit","Spawnpoinit","Spawnpoinit","Spawnpoinit","Spawnpoinit","Spawnpoinit",]

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

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

            local Sword = ServerStorage.Sword:Clone()
            Sword.Parent = game.Workspace.StartPack

            local GameTag = Instance.new("BoolValue")
            GameTag.Name = "GameTag"
            GameTag.Parent = player.Character
        else
            if not player then
                table.remove(plrs,i)
            end
        end
    end
end
0
well, that "SpawnPoinit" table is actually just a comment left by the original creator, although i misspelled it. I tried inputting "SpawnPoint" into the parenthesis of GetChildren() but it still did not work. megatre 5 — 3y
0
isn't this from alvinblox? Check out his tutorial Lightning_Game27 232 — 3y
0
Plus, I do not thing "GetFirstChild" is a thing. it is "FindFirstChild" Lightning_Game27 232 — 3y
Ad

Answer this question