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

Is there a way to CFrame a player's body?

Asked by 7 years ago

I'm trying to CFrame my players body so that it smoothly transitions from point A to point B, can i do this without an animation?

0
What do you mean of animation, like instantly moving there without seeing them move, or seeing the character move but no walking looking act. Jxemes 75 — 7y
0
If you are trying to teleport the player, you can set the CFrame of the HumanoidRootPart MrLonely1221 701 — 7y
0
What i mean is when i press a key.. It slowly cframes the character to a point. XxmanwolfxXalt -2 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Yes there is.

If you have the Player objectType of the player (the one found in game.Players) then you can access their character (game.Workspace) with this handy line of code:

--Find the player object using a known username
local player = game.Players["PLAYER NAME HERE"]
--Set playerCharacter to that players character.
local playerCharacter = player.Character

If you have their character or a specific username, then use

local playerCharacter = workspace["PLAYER NAME HERE"]

If you're using R15 player models in your place, you can then change the CFrame of the HumanoidRootPart, like so:

--Finds and sets the player's character in workspace
local playerCharacter = workspace["PLAYER NAME HERE"]

--Find the HumanoidRootPart in the player's character, and sets a CFrame 20 studs above the centre of the map.
playerCharacter.HumanoidRootPart.CFrame = CFrame.new(0,20,0)

If you're still using R6 player models then you do the same thing, but instead use the Head or Torso. Generally the Torso is used, as more of a standard than anything else:

--Finds and sets the player's character in workspace
local playerCharacter = workspace["PLAYER NAME HERE"]

--Find the Torso in the player's character, and sets a CFrame 20 studs above the centre of the map.
playerCharacter.Torso.CFrame = CFrame.new(0,20,0)

Hope this helped!

Ad

Answer this question