Teleporting Questions

Hey! My name is Div.

Anyone who knows how I can teleport like a player ontop of something? Like when he is clicking on the part, is his not getting teleported into the part. But he is getting on top of the part.

Best Regards,
DivScripts

Offset the y value of the end point by the half the character’s height. Usually Humanoid.HipHeight works fine

1 Like

Create another not visible and not collidable part that is higher and then teleport to there.

What I’d do is localize the CFrame of the part that you want to teleport to:

local PartCFrame = workspace.Part.CFrame --Part is the part you want to teleport to

and then when something is clicked, set the player’s CFrame to the Part’s CFrame.

Note: You should offset the Y value like @steven4547466 said or else he’ll get stuck in the part

And how would I do that with Terrain? xd

Because that I would need too

You could put an invisible part in the terrain and do the same thing, or you can just set the CFrame to a specific CFrame like

local myCFrame = CFrame.new(vec3Pos, vec3LookAt)

So ima have to illustrate this a little so you understand mind my horrible drawings
image
Ok so we must actually mark the point where the position vector is given according too, which always in the centre.
image
You can imagine that if you’re going to change the players position to the red mark you’re of course going to clip into the part.
Now what we can get is the Y size of a part which the value of the pole shown below…
image
Now thats the whole part so we of course want to get anything above the part, this means we must halve the y size, so assuming we have a variable called part

local part = -- the part
local position = part.Position + Vector3.new(0,part.Size.Y/2,0)

Hope that explains it

Holy moly… Then I have to put one hundred parts into my terrain… Isn’t theres any way to check like if the humanoid is under terrain / in part and tp him then up?

I understanded it. But still not solves my problem with the terrain… xd

What exactly are you trying to make with so much teleporting?

Technically yes, but I don’t think it’s very practical

So. I press M. My char gets teleported to the Position of his Mouse. When I do this it sometimes bugs into the Part / Terrain. Spell game.

Ohh okay, so can’t you just teleport the player to the mouse cursor’s position instead of laying down hundreds of parts?

As I said. When I teleport the player he sometimes glitchs under the Terrain or in a part.

Can we see the script or at least the bit that teleports the player and how you get the position?
Usually if you are glitching under terrain we would offset it but you saying…

Kinda makes me clueless on what might be causing a relatively simple tp script :confused:

1 Like

Call :MoveTo on the character.

You’re right, sorry I forgot. Okay, assuming the script is a local script, try this:

-->> Assuming some variables existence:
local RootPart = player.Character:WaitForChild("HumanoidRootPart")
local mouse = player:GetMouse()

local function teleport()
	RootPart.CFrame = mouse.Hit * CFrame.new(0,humanoid.HipHeight,0)
	-->> This part makes it so that the player doesn't clip through the ground
end


UIS.InputBegan:Connect(function(input,processed)
	if processed then return end

	if input.KeyCode == Enum.KeyCode.M then
		teleport()
	end

end)

Since mouse.Hit returns a CFrame value, we can offset the height by multiplying it by another CFrame and then set the RootPart’s CFrame to that value.

1 Like

Oh I understand… Thank you! Thank you so much!

1 Like

You’re welcome, but also thanks to @CreepingGamingTV for that very good art :coefficients: and @steven4547466 mentioning Humanoid.HipHeight which I didn’t know about until now

1 Like