Teleporting to CFrame in Table


So I’m trying to make a command through Basic Admin Essentials that teleports a player to a specific part in the map based on a table of possible locations.

For context, I know how to make the table of locations, but how would I script it so the player has to choose one of those options (Location1, Location2, etc.) and then teleports the player to the specified part’s CFrame?

:goto Location1 (teleports player to Location1’s CFrame)

:goto Location2 (teleports player to Location2’s CFrame)

Hopefully someone can help as this has been plaguing me for a while.

I’ll link a few topics for reference as well:

Hi there, apologies for the delayed response let’s get you the help you need.

So I’ve just had a chance to get BAE and check out how their custom commands work, and it’s actually reletively simple. I found that it might be easier to create a different command using their plugins instead of trying to override the goto command. In this case I created a plugin command and made the command gotol

Then using the example plugin provided I made some small adjustments to come up with this very simple script:

As you can see, I have defined the table of zones/locations at the top of the script, since it was convinient to put it there, and BAE does the rest, all you need to do is utilize the arguments. You can get the player’s character by using the Player variable defined at the start of the pluginFunction function and teleport that around.

If you have any questions let me know :slight_smile:

local Locations = {
	location1 = {,0,0),,0,5)
	location2 = {,0,0),,0,2)

local Plugin = function(...)
	local Data = {...}
	-- Included Functions and Info --
	local remoteEvent = Data[1][1]
	local remoteFunction = Data[1][2]
	local returnPermissions = Data[1][3]
	local Commands = Data[1][4]
	local Prefix = Data[1][5]
	local actionPrefix = Data[1][6]
	local returnPlayers = Data[1][7]
	local cleanData = Data[1][8] 
	local pluginName = 'gotol'
	local pluginPrefix = Prefix
	local pluginLevel = 1
	local pluginUsage = "Zone Name"
	local pluginDescription = "Hey, this is a plugin example.\nIt's also multi-line!"
	local function pluginFunction(Args) -- keep the name of the function as "pluginFunction"
		local Player = Args[1] -- Player who ran the command
		if Args[3] then -- Checking if a location name was given
			local Location = Locations[Args[3]:lower()] -- Finding the location name without needing to be case sensitive
			if Location then -- Making sure it exists
				-- Then here you can teleport the player to a random location from the table.
				print('Teleport', Player, 'to random location in', Args[3], 'Location:', Location[math.random(#Location)])
	local descToReturn
	if pluginUsage ~= "" then
		descToReturn = pluginPrefix..pluginName..' '..pluginUsage..'\n'..pluginDescription
		descToReturn = pluginPrefix..pluginName..'\n'..pluginDescription
	return pluginName,pluginFunction,pluginLevel,pluginPrefix,{pluginName,pluginUsage,pluginDescription}

return Plugin
1 Like

Assuming this works (because I can’t test it at the moment), you have just solved a problem that has been stuck on my mind for months.

If it works, all I can say is thank you so so much!

Edit: I won’t set it as the solution yet because I can’t test this until tomorrow

Here is a GIF of it in action:

Output: Teleport sl0th_two to random location in location1 Location: 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1

If you need any urgent/in-depth help regarding this topic you can contact me quicker on Discord: sl0th#5669

1 Like

Thank you for providing that.
I’ll still test the teleport side of things tomorrow, but it is good to see that the code runs as expected, providing an output.

If I run into any issues, I shall let you know.

1 Like

I have sent you a request; I’ve done some testing and some issues have arisen.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.