How would I move a player to a part?

Here we go.

I am trying to create a script that will move a player to a part. I have a script setup so when they buy the item, it will wait 5 seconds, then move the player to a parts position where their item is located. The part i can’t figure out is moving the player to the part. Heres a example:

script.Parent.MouseButton1Click:Connect(function(Player)
local Char = Player.Character
Char.Position = game.Workspace.TPPart.Position

How can i get this working?

6 Likes

Also, this is a local script in a screen gui :stuck_out_tongue:

Char.HumanoidRootPart.CFrame = game.Workspace.TPPart.CFrame
7 Likes

huh, lemme test that. What does CFrame even mean/do?

@polill00 would teleport the player to the part. If you want that make sure to add a positive y vector so they dont clip. If you want it to move to it smoothly you would use the method humanoid:MoveTo(vector) make sure to apply a animation when this happens else it will kinda just slide. And make sure to do this on the server!

2 Likes

From my understanding CFrame is just like vector3 except it also has rotational imaginary numbers aka rotational matrix

Wow! It worked PERFECTLY. All I really will need to do now is add a wait to make it more smooth, but, with what @Diamond_Plus1 said, i am not having any clipping issues, so i should be fine on that part

CFrame , short for coordinate frame , is a data type that describes a 3D position and orientation. It is made up of a positional component and a rotational component. It includes essential arithmetic operations for working with 3D data on Roblox.

1 Like

Make sure to mark his response as a solution so it helps others

Setting the players position would work too, It doesn’t pass in orientation though.

Your problem was that you weren’t applying the position to the HumanoidRootPart.

@Diamond_Plus1 was referring to if you placed the tp part on the ground (or if it was cancollide = true, it would clip the player up to the surface.

Actually assuming his player is constructed with motor6ds and not just 1 part you NEED to use cframe

2 Likes

Thanks for the help, i got it working

  • List item

One last problem i just noticed; I am moving a vehicle from Rep Storage to Workspace, and whenever i move it, the seats no longer work? Ive tested it without moving it to rep storage, and it works fine

In roblox the CFrame is an instance composed of 3 numbers, which represent the 3 axes of the three-dimensional workspace, namely X, Y and Z. The CFrame is used most of the time to change the position of any material instance that has this three-dimensional property . I hope I have been of help to you!

1 Like

This topic has already been solved last year.

1 Like