Help moving players's character behind a door

I have a door script that plays a cutsence when the proximityPrompt is triggerd, but the problem is I dont know how to teleport the player on the otherside. I want to achieve this by moving the player character 5 studs on the other side of the door. My best guess was to use the players’s HRP lookvector, yet I couldnt figure that out, and thats flawed.


an image for refrence

local cutscene = require(script.Parent.Cutscene)

local door = {}

function door.new(model: Model)
	
	local self = setmetatable({}, {__index = door})
	
	self.proximityPrompt = Instance.fromExisting(script.Prompt)
	self.model = model
	
	return self
	
end

function door:Initilize()	
	self.proximityPrompt.Parent = self.model
	
	self.proximityPrompt.TriggerEnded:Connect(function(player:Player)
		self.proximityPrompt.Enabled = false
		
		local newCutscene = cutscene.new()
		
		for _,v in pairs(player.Character:GetChildren()) do
			pcall(function() v.Anchored = true end)
		end
		
		newCutscene:Play(function() -- callbackfunction
			player.HumanoidRootPart.Postition = --teleport code here
			for _,v in pairs(player.Character:GetChildren()) do
				pcall(function() v.Anchored = false end)
			end
			task.delay(4, function() self.proximityPrompt.Enabled = true end) --debounce
		end)
				
	end)
end

return door

the door script (uses collection service, the doors are tagged)

also want to point out I dont want to have to create 2 parts to teleport from each side of the door, that would be a hassle to implment.

I dunno if you mean this

local char = plr.Character
local part = script.Parent.Parent
local newPos = part:GetPivot():ToWorldSpace() * CFrame.new(Vector3.new(0,0,2))
char:PivotTo(newPos)

It teleports the player relative to the rotation of the part
image

that works but I still need a way to check which side the door is being opened from.
raycasts?

Yes. (Try using .Dot() and .Cross()) , good luck.

1 Like

Just a question, but why teleport them?
Why not just Tween the door open and let the player walk through?

well why open the door when you can teleport through it in style

1 Like

The system is inspired by this “Cool Loading Screens?” by OoferGuide.

1 Like

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