Portal spawning incorrectly

I am making a sort of portal ability in my game, however whenever it spawns in front of the player, it spawns either too higher or too lower depending on the player’s location. I am not receiving any sort of errors, and I have tried using a tween to make it go lower by 3 studs, however this only solves the issue on a certain part of the map, here is the script, if you have a possible solution please inform me:

local assets = game.ServerStorage.Assets.Abilities.Door
local plr = script.Parent.Parent.Parent
local char = plr.Character
local ts = game:GetService("TweenService")
local plrs = game:GetService("Players")
local enabled = false
local opened = false
local entered = false
local cooldown = false
local door
local part

script.Parent.Activated:Connect(function()
	if enabled == false then
		enabled = true
		door = assets.Door:Clone()
		local HRP = plr.Character.HumanoidRootPart
		local distance = 10
		local pos = HRP.Position + (HRP.CFrame.LookVector)*distance
		local primarypart = door.PrimaryPart
		door.Parent = workspace
		pos =  pos
		door:MoveTo(pos)

		local tweenInfo = TweenInfo.new(

			3,
			Enum.EasingStyle.Linear,
			Enum.EasingDirection.InOut,
			0,
			false
		)

		local tweenInfo2 = TweenInfo.new(

			0,
			Enum.EasingStyle.Linear,
			Enum.EasingDirection.InOut,
			0,
			false
		)

		local goal1 = {

			Transparency = 0
		}

		local goal2 = {

			Color = Color3.fromRGB(127, 78, 0)

		}

		local goal3 = {

			Position = primarypart.Position - Vector3.new(0,2.5,0)

		}

		local goal4 = {

			Transparency = 1

		}

		for i,v in pairs(door:GetChildren()) do
			part = v
			local tween1 = ts:Create(part, tweenInfo, goal1)
			local tween2 = ts:Create(part, tweenInfo, goal2)
			local tween3 = ts:Create(part, tweenInfo2, goal3)
			spawn(function()
				tween3:Play()
				wait()
				door:SetPrimaryPartCFrame(CFrame.lookAt(primarypart.CFrame.Position, char.HumanoidRootPart.Position))	
				tween1:Play()
				wait(3)
				if v.Name ~= "Door" then
					tween2:Play()
					wait(3)
					v.Material = Enum.Material.Wood
				end
			end)
		end
		wait(6)
		opened = true
		door.Door.Touched:Connect(function(t)
			if t.Parent:FindFirstChild("Humanoid") then
				if opened == true then
					if cooldown == false then
						cooldown = true
						if entered == false then
							entered = true
							t.Parent:MoveTo(game.Workspace.Map.InbetweenSpawn.Position)
						else
							entered = false
							t.Parent:MoveTo(game.Workspace.Map.Locations["S,"..plrs:FindFirstChild(t.Parent.Name).ValueFolder.Spawn.Value].Position)
						end
						wait(1)
						cooldown = false
					end
				end
			end
		end)
		wait(3)
		opened = false
		for i,v in pairs(door:GetChildren()) do
			local tween4 = ts:Create(v, tweenInfo, goal4)
			spawn(function()
				tween4:Play()
				wait(3)
				v:Destroy()
			end)
		end
		wait(5)
		enabled = false
	end
end)