Yes, it should be a regular script.
Is there a way to make it so you have to wait a certain amount of time before it chooses a map/teleports you. Can I just do wait(1) for an example before the teleport part of the script?
Theres also another problem it chooses the map but doesn’t teleport. Do I have to set something? I noticed theres a teleport position were I set but I wasn’t quite sure
You can put
game.Players.PlayerAdded:Wait(2)
at the top of the script. This prevents the script from running before the player joins the game.
And yes, you need to put a certain position.
How can I make it so It teleports in the middle
Just place a part in the middle of the map and refer to my script:
local maps = {1,2,3,4}
local chosen = maps[math.random(1,#maps)]
chosen.Name = "ChosenMap"
chosen.Parent = workspace
for _, player in pairs(game.Players:GetPlayers()) do
player.Character.CFrame = workspace.ChosenMap.SpawnPart.CFrame -- spawn part is the part you want all players to teleport you to
end
Hello.
Firstly, player.Character.CFrame
is not a thing. You need to use SetPrimaryPartCFrame
. Second, you should use GetChildren
with a folder in ServerStorage
, as I did. Finally, you need to clone the map, or else the map will disappear from ServerStorage
.
Other than that, using a part is a good idea and it saves work.
That was my Idea I can use both. To be honest if there is some way of doing that it would be great.
I can replace the teleport from your script and replace it with his?
I’m really stuck on this. (30 chars)
I’ve just removed the TeleportPosition
variable and replaced the TeleportCFrame
variable with the CFrame of the part.
local Maps = game.ServerStorage.Maps:GetChildren() -- Gets the children of maps
local Rand = math.random(1, #maps) -- Picks a random number from 1 to the number of maps
local TeleportCFrame = game.Workspace.TeleportPosition.CFrame -- This is the part where you would get teleported.
Maps[Rand]:Clone().Parent = workspace -- Picks the random map by indexing it with the random number and cloning it into the workspace.
for _, Player in pairs(game.Players:GetPlayers()) do -- Loops through all the players in-game.
if Player.Character then -- Checks if the player has a character. Players might not have a character when they first join in to the game, or when their character is respawning.
Player.Character:SetPrimaryPartCFrame(TeleportCFrame) -- Sets the character's CFrame to the teleport CFrame. Basically moving the character.
end
end
Now it’s not cloning or is it because I haven’t configured the teleport yet?
my way is just having one part that constantly moves to different maps with CFrame so it randomly picks XD
So I use this script all the time make a script in serverscriptservice.
Now inside the script insert a module script.
Also make a folder inside Replicated Storage and put all the maps inside the folder(I’m naming it maps.)
Now type this script inside the module Script.
function module.SelectMap()
local rand = Random.new()
local chapters = game.ReplicatedStorage.Maps:GetChildren()
local choosedchapter = chapters[rand:NextInteger(1, #chapters)] -- this will choose any one map from the folder.
return choosedchapter
end
if you want to teleport them to the map make a part inside every map and name it mapSpawn.(Type in module script)
function module.teleportPlayers(players, mapSpawns)
for i, v in pairs(players) do
if v.Character then
local character = v.Character
if character:FindFirstChild("HumanoidRootPart") then
local rand = Random.new()
v.Character.HumanoidRootPart.CFrame = mapSpawns[rand:NextInteger(1, #mapSpawns)].CFrame + Vector3.new(0, 10, 0)
end
end
end
end
Now go to your script and type this
local Round = require(script.ModuleScript)
local ChoosedMap = Round.SelectMap()
local ClonedMap = ChoosedMap:Clone()
ClonedMap .Parent = workspace
ClonedMap .Name = "ClonedMap"
if ClonedMap :FindFirstChild("mapSpawns") then
Round.teleportPlayers(ClonedMap .mapSpawns())
else
warn("Error no teleporot spawns")
end
I just get a bunch of errors…
can you show me the output?
30 charss
I blurred the parts that are not part of it
Sorry I didn’t put the whole script.
Now I have edited it.
Try now.
It’s red underlining module… In the module script