How to change a character's position, When I'm making a script, it says that position isn't a valid member of a character. Any help?
How to change a character's position?
3 answers
This is how you teleport or change the players position. We can use 3 different things to teleport. 1. CFrame, 2. MoveTo, 3. SetPrimaryPartCFrame. I know you already accepted an answer but most people don't know that there are 3 ways to teleporting a player.
CFrame. This is easy.
workspace.Player.Torso.CFrame = CFrame.new(0,0,0) --Teleport
Next is moveto function,
workspace.Player:MoveTo(Vector3.new(0,0,0)) --Moves the model
Last is SetPrimaryPartCFrame
workspace.Player:SetPrimaryPartCFrame(CFrame.new(0,0,0)) --Teleports the primary part and also teleport the objects in the model.
I hope it helps!
To teleport ALL the players, do this:
for i, player in ipairs(game.Players:GetChildren()) do
if player.Character and player.Character:FindFirstChild("Torso") then
player.Character.Torso.CFrame = CFrame.new(0,0,0) + Vector3.new(0, i * 5, 0)
end
end
Teleports each player and teleports each player on top of each other so they don't get stuck inside each other.
If you want to teleport players from a game to another game use the TeleportationService. For example:
script.Parent.Touched:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
game:GetService("TeleportService"):Teleport(8473728, player) --Teleport the player to a game with an ID of 8473728
end
end)
This is what you use for GUIs. THIS IS FOR LOCAL SCRIPT ONLY.
script.Parent.MouseButton1Click:connect(function()
local player = game.Players.LocalPlayer --LocalPlayer
if player then
game:GetService("TeleportService"):Teleport(8473728
end
end)
Use the MoveTo() method.
Character:MoveTo(Vector3.new(0, 0, 0))
Make sure to define Character and stuff, and you can of course replace the Vector3 values.
EDIT: You could also use CFrame, but that's if you're teleporting to a part. If you need a tutorial on CFrame, just comment.
2 comments
Yeah I'd like to know how to do that with CFrame please?
Just set the CFrame of the torso. character.Torso.CFrame = CFrame.new(0, 0, 0). Also, look up CFrame on the wiki.
character.HumanoidRootPart.CFrame = CFrame.new(0,20,0) --where character is a reference to the player's character, and CFrame.new() contains the desired position
6 comments
Doesn't work, you need to change the TORSO's Cframe.
What do you mean? It's worked for me before. Additionally, it teleports the camera instead of the torso. And when I say before, I mean this morning.
I tested it again, works just fine, so please remove your downvote.
Now where is your explanation? What is character? Is it a variable? Why do you have to do CFrame.new istead of Vector3.new?
He asked how he could move the player using CFrames, he didn't ask about CFrames, so stop being a devil's advocate and if you care so much do it yourself. Besides, I already said what character was.
SetPrimaryPartsCFrame is also CFrame. I would recommend Torso because the torso has all the welds in it.
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Question, Won't the first thing , I mena CFrame move the player named Player?
brokenrares of course, It's just for an example though.
You are doing this way to complicated! For GUI's you should do script.Parent.MouseButton1Click:Connect(function() game:GetService("TeleportService"):Teleport(00000000) end end) -- This is in 1 line and way shorter also very easy to understand