CFrame Table Not Working?

Hello,

I’m basically trying to make teleports for my vibe game, but sadly it’s not working. This is the method I’m trying to use. (No errors, it just tps me somewhere else)

local Positions = {
	VibeCinema = {1181.50806, 442.257599, -3646.05176}; -- [1]
	VibeSpawnArea = {1178.79736, 439.534393, -3814.00488}; -- [2]
	VibeGym = {-47.6673622, -275.558136, -7142.46143}; -- [3]
	VibeDorms = {-1443.43567, 170.433762, -8402.49805}; -- [4]
	VibeShop = {1461.14063, 270.887054, -6908.63965}; -- [5]
	VibeShow = {-575.485168, -205.383591, -7456.58984}; -- [6]
	VibeSchool = {-36.4238281, 418.362762, -7722.33887}; -- [7]
	VibeMuseum = {-32.2998581, -140.406586, -6815.56738};  -- [8]
	VibeLibrary = {-1499.82849, 33.7866287, -7180.29004}; -- [9]
	VibeClass = {1052.64929, 463.796967, -4009.90112}; -- [10]
}

function TeleportToPos(...)
	local Info = TweenInfo.new(3, Enum.EasingStyle.Quad)
	local Tick = tick();
	local Params = {...};
	local TempCFrame = CFrame.new(Params[1], Params[2], Params[3]);
	local Tween, Nil = pcall(function()
		local TempTween = Variables.TweenService:Create(Variables.Character["HumanoidRootPart"], Info, {CFrame = TempCFrame});
		TempTween:Play();
	end)
	if not Tween then 
		return Nil 
	end
end

TeleportToPos(Positions[1])

I’ve also tried using TeleportToPos(Positions.VibeCinema), but unfortunately it still teleports me somewhere else. (Keep in mind, the CFrame positions do work if I do it like this; TeleportToPos(1181.50806, 442.257599, -3646.05176), meaning that the CFrame positions are correct.

Why not create a spawning block for each location you would like to teleport to? You could simply get the CFrame of the spawning block and it would be much more reliable if let’s say you decide to shift the map to a completely new position.

Not to mention it makes your code look much less underwhelming than having 5-10 different Vector positions :slight_smile:

1 Like

I guess, but right now I’d rather use the raw CFrame value method. If it does come to it, I’ll rewrite it and make parts.

I believe your problem is in this line:

	local TempCFrame = CFrame.new(Params[1], Params[2], Params[3]);

You’re basically trying to index a vector value to a CFrame. Try doing something along the lines of:

local TempCFrame = CFrame.new(Vector3.new(Params[1], Params[2], Params[3]));

Wait so CFrame.new(Vector3.new?

Yes!! Since you are trying to find the position of the part, you have to use the Vector value :slight_smile:

1 Like