Still have questions? Join our Discord server and get real time help.
Log in to vote

Issues with teleporting players to spawn points of a random map?

Asked by 22 days ago

I've made a game loop for my game.

Before the game starts, the script selects a random map out of a certain folder and teleports all players in the game to it.

Here's the script, let me know if anything seems off. (It's in a Server Script in ServerScriptService if that helps)

local maps = game.Lighting.Maps:GetChildren() --Gets maps

    chosenMap = maps[math.random(1,#maps)] --Chooses random map
    chosenMap:Clone().Parent = workspace --Clones it and puts it in Workspace

    for i,v in pairs(game.Players:GetChildren())do
        if v.Character then
            v.Character.Torso.CFrame = workspace:FindFirstChild(chosenMap.Name).Spawns.CFrame

What's happening is that it keeps the player inside the designated intermission location (a building I created) and the script doesn't allow any of the players to be teleported.

What's weird is that the script was working just fine earlier, I don't think I made any changes that should affect the teleportation.

My output states that "CFrame is not a valid member of Folder"

Don't think you need to put the name after chosenMap since the script already knows what the map is. I also recommend you look into "Character:MoveTo()" for the teleporting part. Player1_Joined 271 — 22d
Try CFrame:GetPrimaryPartCFrame() Dovydas1118 795 — 22d

Answer this question