Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make it so you can teleport people i tried?

Asked by 8 years ago

game.Workspace.Player.LocalPlayer.CFrame = CFrame.new(Vector3.new(0,50,0))

2 answers

Log in to vote
0
Answered by 8 years ago
game.Workspace.Player.LocalPlayer.CFrame = CFrame.new(Vector3.new(0,50,0))

You cannot get a player by using the code you used.

You access the player by doing the following:

game.Players.LocalPlayer

This needs to be in a local script,

You can get the character and torso cframe by doing the following:

game.Players.LocalPlayer.Character.Torso.CFrame = CFrame.new(0,50,0)

2nd issue, dont use Vector3.New inside if a userdata value, such as CFrame.new(*****)

Ad
Log in to vote
0
Answered by
StoIid 364 Moderation Voter
8 years ago
Edited 8 years ago

You are very close to solving this (not really) but I will tell you what you are doing wrong, and then help you solve it.

To begin..

game.Workspace.Player.LocalPlayer This already should throw an error. Player is not a thing in Workspace (well at least not the one you're attempting to get), it is a property of the DataModel called game.

What this means is instead of doing game.Workspace, you'd do game.Players. In this, you will find all the PlayerObjects of the players connected to he game. To get the player that is theoretically "you" simply do what you did with the term LocalPlayer; game.Players.LocalPlayer.

Now that you've done this, you can now get the Character of the player by doing .Character; game.Players.LocalPlayer.Character. This will return the players Character model that is located in the workspace (if it's not there, it will throw an error).

Now onto the CFraming. For "safe teleporting" you should manipulate the Torso's CFrame; game.Players.LocalPlayer.Character.Torso. This will give pretty decent "accuracy" when moving the player.

Now the second part of what you did wrong was when you were manipulating the CFrame, setting it equal to CFrame.new(Vector3.new(0,50,0)). This is not what you want to do, what you want to do is set it equal to the CFrame of another object EX: a part in the workspace. You accomplish this by doing workspace.Part.CFrame. If you would like to "offset" it then simply combine it with a newly constructed CFrame with CFrame.new().

0
I can give you a single line code sample for you to use if you cannot solve it still, but I'd like you to read what I have given first for you to try and understand rather than just copy and paste and not learn ANYTHING. :) just comment below if you need help. StoIid 364 — 8y

Answer this question