Script teleports me far away from part?

So I have this script where if you own specific badges it’ll teleport you to a part & will also do other things, now everything in the script is working fine except for the part where it teleports me, I always end up outside or not exactly where the part is positioned, how do I fix that so that I always get teleported to exactly where the part is? (the part is called FinalTP under Workspace)

Current server script (inside a part inside a model):

local Players = game:GetService("Players")
local TeleportService = game:GetService("TeleportService")
local BadgeService = game:GetService("BadgeService")

local rs = game:GetService("ReplicatedStorage")
local model = rs:WaitForChild("Podium") --change to name of model in replicated storage
local pos = game.Workspace.PosPoint.CFrame


local Badges = {2147284665, 2147284674, 2147284683, 2147313047, 2147313055} -- Put your badgeID's here
local dbs = {}

local function hasBadges(plr)
	for _,badge in pairs(Badges) do
		local success, hasBadge = pcall(function()
			return BadgeService:UserHasBadgeAsync(plr.UserId, badge)
		end)

		if success and not hasBadge then
			return false
		end
	end

	return true
end

script.Parent.Touched:Connect(function(obj)
	local plr = Players:GetPlayerFromCharacter(obj.Parent)

	if plr then
		if not dbs[plr.Name] then
			dbs[plr.Name] = true

			if hasBadges(plr) then
				print(plr.Name.." has all the required badges.")

					local h = obj.Parent:FindFirstChild("Humanoid")
					if (h~=nil) then
					h.Parent:SetPrimaryPartCFrame(workspace.FinalTP.CFrame)
					end


				model.Parent = workspace
				model:SetPrimaryPartCFrame(pos.CFrame)

			else
				print(plr.Name.." does NOT have all the required badges.")
			end

			dbs[plr.Name] = false
		end
	end
end)
1 Like

In my experiences and others, set primary parts is not a very good way to position players. Instead I recommend using the pivotto() function.

1 Like

Seems like the issue is with the area I’m trying to teleport to, I’m trying to teleport inside a hollow box (part) but for some reason it always puts me outside instead of inside, not sure how to fix that…

If the box is a model/union the player will be teleported outside the MODELS boundary box, not the physical components of the model/union. Try to be de-unionize or ungroup the box asset.

1 Like

It was a normal part, made it a union, and did as you said, seems to work. Thanks!!

1 Like