Basic Admin Essentials - Teleport to part

So I recently set up Basic Admin Essentials in my game for admin purposes. I have tested it and it works fine (with commands that affect any player but yourself like :kick or :ban not being tested yet).

I am aware that it is possible to create a command that allows you to teleport to a specific spot in your map. For example, if I made a custom command called :location.

Examples:
If I said :location city, it would teleport me to the city area.
If I said :location forest, it would teleport me to the forest area.

Can anyone provide any assistance on how to set this up? I have provided a snippet of the code where I believe it would need to be done:

function Funcs.Teleport(Args)
	local Player = Args[1]
	if Args[2] == 'tp' then
		if not Args[4] then return end
		local Target = returnPlayers(Player,Args[4],Args[2])[1] if not Target then return end
		local Players = returnPlayers(Player,Args[3],Args[2]) if not Players then return end
		for a,b in pairs(Players) do
			local bHumanoid, bHumanoidRootPart = 
				b.Character:FindFirstChildOfClass("Humanoid"), b.Character:FindFirstChild("HumanoidRootPart")
			local tHumanoidRootPart = Target.Character:FindFirstChild("HumanoidRootPart")
			if bHumanoid ~= nil and bHumanoidRootPart ~= nil and tHumanoidRootPart ~= nil then
				if bHumanoid.SeatPart ~= nil then
					local AlreadyUnSitting = bHumanoid:FindFirstChild("BasicAdmin_Unsitting")
					if not AlreadyUnSitting then
						AlreadyUnSitting = Instance.new("Folder")
						AlreadyUnSitting.Name = "BasicAdmin_Unsitting"
						AlreadyUnSitting.Parent = bHumanoid
						spawn(function()
							local Condition = (bHumanoid.SeatPart == nil and bHumanoid.Sit == false) or (bHumanoid.Parent.Parent == nil) or (not bHumanoid:IsDescendantOf(b.Character))
							repeat
								bHumanoid.Sit = false
								Condition = (bHumanoid.SeatPart == nil and bHumanoid.Sit == false) or (bHumanoid.Parent.Parent == nil) or (not bHumanoid:IsDescendantOf(b.Character))
								if Condition == true then
									break
								else
									wait(0.1)
								end
							until Condition == true
							if (bHumanoid.Parent.Parent ~= nil) and (bHumanoid:IsDescendantOf(b.Character)) then
								for c,d in next,bHumanoid:GetChildren() do
									if d.Name == "BasicAdmin_Unsitting" then
										d:Destroy()
									end
								end
								bHumanoidRootPart.CFrame = (tHumanoidRootPart.CFrame*CFrame.Angles(0,math.rad(90/#Players*a),0)*CFrame.new(5+.2*#Players,0,0))*CFrame.Angles(0,math.rad(90),0)
							end
						end)
					end
				else
					bHumanoidRootPart.CFrame = (tHumanoidRootPart.CFrame*CFrame.Angles(0,math.rad(90/#Players*a),0)*CFrame.new(5+.2*#Players,0,0))*CFrame.Angles(0,math.rad(90),0)
				end
			end
		end
	elseif Args[2] == 'to' then
		local playerRoot = Player.Character:FindFirstChild('HumanoidRootPart')
		local playerHumanoid = Player.Character:FindFirstChildOfClass("Humanoid")
		if playerRoot ~= nil and playerHumanoid ~= nil then
			local Players = returnPlayers(Player,Args[3],Args[2]) if not Players then return end
			for a,b in pairs(Players) do
				local bHumanoidRootPart = b.Character:FindFirstChild("HumanoidRootPart")
				if bHumanoidRootPart ~= nil then
					if playerHumanoid.SeatPart ~= nil then
						local AlreadyUnSitting = playerHumanoid:FindFirstChild("BasicAdmin_Unsitting")
						if not AlreadyUnSitting then
							AlreadyUnSitting = Instance.new("Folder")
							AlreadyUnSitting.Name = "BasicAdmin_Unsitting"
							AlreadyUnSitting.Parent = playerHumanoid
							spawn(function()
								local Condition = (playerHumanoid.SeatPart == nil and playerHumanoid.Sit == false) or (playerHumanoid.Parent.Parent == nil) or (not playerHumanoid:IsDescendantOf(b.Character))
								repeat
									playerHumanoid.Sit = false
									Condition = (playerHumanoid.SeatPart == nil and playerHumanoid.Sit == false) or (playerHumanoid.Parent.Parent == nil) or (not playerHumanoid:IsDescendantOf(b.Character))
									if Condition == true then
										break
									else
										wait(0.1)
									end
								until Condition == true
								if (playerHumanoid.Parent.Parent ~= nil) and (playerHumanoid:IsDescendantOf(b.Character)) then
									for c,d in next,playerHumanoid:GetChildren() do
										if d.Name == "BasicAdmin_Unsitting" then
											d:Destroy()
										end
									end
									playerRoot.CFrame = (bHumanoidRootPart.CFrame*CFrame.Angles(0,math.rad(90/#Players*a),0)*CFrame.new(5+.2*#Players,0,0))*CFrame.Angles(0,math.rad(90),0)
								end
							end)
						end
					else
						playerRoot.CFrame = (bHumanoidRootPart.CFrame*CFrame.Angles(0,math.rad(90/#Players*a),0)*CFrame.new(5+.2*#Players,0,0))*CFrame.Angles(0,math.rad(90),0)
					end
				end
			end
		end
	elseif Args[2] == 'bring' then
		local playerRoot = Player.Character:FindFirstChild('HumanoidRootPart')
		if playerRoot ~= nil then
			local Players = returnPlayers(Player,Args[3],Args[2]) if not Players then return end
			for a,b in pairs(Players) do
				local bHumanoid, bHumanoidRootPart = 
					b.Character:FindFirstChildOfClass("Humanoid"), b.Character:FindFirstChild("HumanoidRootPart")
				if bHumanoid ~= nil and bHumanoidRootPart ~= nil then
					if bHumanoid.SeatPart ~= nil then
						local AlreadyUnSitting = bHumanoid:FindFirstChild("BasicAdmin_Unsitting")
						if not AlreadyUnSitting then
							AlreadyUnSitting = Instance.new("Folder")
							AlreadyUnSitting.Name = "BasicAdmin_Unsitting"
							AlreadyUnSitting.Parent = bHumanoid
							spawn(function()
								local Condition = (bHumanoid.SeatPart == nil and bHumanoid.Sit == false) or (bHumanoid.Parent.Parent == nil) or (not bHumanoid:IsDescendantOf(b.Character))
								repeat
									bHumanoid.Sit = false
									Condition = (bHumanoid.SeatPart == nil and bHumanoid.Sit == false) or (bHumanoid.Parent.Parent == nil) or (not bHumanoid:IsDescendantOf(b.Character))
									if Condition == true then
										break
									else
										wait(0.1)
									end
								until Condition == true
								if (bHumanoid.Parent.Parent ~= nil) and (bHumanoid:IsDescendantOf(b.Character)) then
									for c,d in next,bHumanoid:GetChildren() do
										if d.Name == "BasicAdmin_Unsitting" then
											d:Destroy()
										end
									end
									bHumanoidRootPart.CFrame = (playerRoot.CFrame*CFrame.Angles(0,math.rad(90/#Players*a),0)*CFrame.new(5+.2*#Players,0,0))*CFrame.Angles(0,math.rad(90),0)
								end
							end)
						end
					else
						bHumanoidRootPart.CFrame = (playerRoot.CFrame*CFrame.Angles(0,math.rad(90/#Players*a),0)*CFrame.new(5+.2*#Players,0,0))*CFrame.Angles(0,math.rad(90),0)
					end
				end
			end
		end
	end
end

For reference, this code can be found in the MainModule script

Like I said, if anyone can provide some insight on how to do this, that would be amazing!

Thank you!
MitchDev47

(this is my first topic here btw :slight_smile:)

1 Like

I would probably make an invisible and noncollide part for city covering the area and when people use that i would teleport them to game.Workspace.City.Position with the Y value changed

1 Like

You can just use :MoveTo with your character. I highly recommend making this a plugin and having the original loader, as BasicAdmin will not update if you fork the MainModule.

1 Like

I will test it out in a different place later today.
Thanks for the response!

I’ll give it a crack and see how it goes. Thanks for the reply!