Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to get player from character?

So I know that this is an Event or something. But I would like to know how to use it. Specifically on this line of code here:

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

It is supposed to teleport you to that position, but it says Player is not a valid member of Workspace. i thought maybe it would recognize player as a local player or something

ALSO! This is a local script in StarterGui, so you may do LocalPlayer.

2 answers

✓ Accepted answer

Since you cant teleport a player, you need to teleport the actual character. You can do this by saying

Plr = game.Players.LocalPlayer
Char = Plr.Character

Char.HumanoidRootPart.CFrame = CFrame.new(0,50,0)

You can't call a player in workspace since you didn't connect it.

This is how its suppose to do it :

local p = game.Players.LocalPlayer
local char = p.Character

char:FindFirstChild("HumanoidRootPart").CFrame = CFrame.new(Vector3.new(0, 50, 0))

This discussion is preserved as it was. New answers, comments, and votes are closed.