Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[SOLVED] For some reason the players are teleported to the baseplate instaed of the map?

So I have a module that helps with map loading and teleporting. The problem is that whenever I teleport the players it teleports them to the baseplate instead of the map which is far away from the baseplate.

I don't think it's the map's problem since the "blue hitbox" which comes up whenever you click the map is nowhere near the baseplate. I think it's the script's fault.

I have a folder which is named "TeleportLocations" and it has parts in there simply named "Part". Whenever I go to print one of the parts it outputs "Part" which I know the script is correctly accessing all the teleport locations.

Here's part of the module script for teleporting a player:

function MapmoduleScript:TeleportPlayer(Player)
	local TeleportLocation = CurrentMap:WaitForChild("Teleports"):GetChildren()
	local RandomTeleport = TeleportLocation[1] -- for now i set it to the first teleport brick

	local Torso = Player.Character.Torso
	local Vector = Vector3.new(RandomTeleport.Position)
	Torso.CFrame = CFrame.new(Vector)
	-- it just teleports me to the middle of the baseplate
end

Then here's part of the server script:

local MapLoader = require(script.Parent.Modules.MapmoduleScript)

local function TeleportPlayers()
	for i,v in pairs(PlayersService:GetPlayers()) do
		MapLoader:TeleportPlayer(v)
	end	
end

local function LoadMaps()
	local MapsLoaded = MapLoader.new(Maps) -- works fine
	MapLoader:LoadMap("First") -- works fine
	wait(2)
	TeleportPlayers() -- teleporting all players
	wait(10)
	MapLoader:CleanUp() -- works fine
	MapLoader:DestroyMap() -- works fine
	Repeat()
end

function Repeat()
	-- an intermission goes here
	wait(2)
	LoadMaps()
end

Repeat()

Basically the function in the module script is for teleporting one player, this function called TeleportPlayers() just calls the module script function to teleport everyone.

I'm not sure if the position is nil or anything for the teleport bricks.

4 comments

0

Please print TeleportLocation[1].Position

0

Firstly, in the module script, I am not sure what "CurrentMap" refers to. Secondly, have you tried printing out "Vector" to see wether its value is not (0,0,0). If so, then you must check the part of the code that generates those random teleports. So far I don't see anything else that could be causing your problem.

0

Ok I will print it and tell you guys

0

It didn't print (0, 0, 0) it printed the teleport's position which is (49, 2, -609)

1 answer

Ok I solved it guys, I was supposed to change the player torso's cframe to the teleport brick's cframe.

Torso.CFrame = RandomTeleport.CFrame

This discussion is preserved as it was. New answers, comments, and votes are closed.