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

Can anyone help me teleport a player to a vector3?

Asked by 3 years ago

I'm trying to make it so that the player teleport in a specific area but it doesn't wanna work

local player = game.Players.LocalPlayer

player.Humanoid.HumanoidRootPart.Position = Vector3.new(54.86, 0.5, -77.58)
0
Changing the position of the HumanoidRootPart on the client will result in the HumanoidRootPart to be moved instead of the entire character. Use CFrame instead of position. MarkedTomato 810 — 3y

2 answers

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

Well, There Is A New And Better Way To Identify The Character:

local Player - game.Players.LocalPlayer -- // This Is You
local MainPos = Vector3.new(54.86, 0.5, -77.58) -- // MainPos .. MainPosition

local Character = game.Workspace:WaitForChild(Player.Name) -- // New Way To Identify The Character
local HumanoidRootPart = Character:WaitForChild('HumanoidRootPart') -- // Identifying The HumanoidRootPart



HumanoidRootPart.Position = MainPos -- // Setting The HumanoidRootPart Pos To MainPos

0
local Character = game.Workspace:WaitForChild(Player.Name) is not a new way of defining the Character, there's obviously a reason why we have a property of the Player which is Player.Character. MarkedTomato 810 — 3y
1
Changing the position of the HumanoidRootPart on the client will result in the HumanoidRootPart to be moved instead of the entire character. Use CFrame instead of position. MarkedTomato 810 — 3y
0
Bro Nobody Understands What You Are Saying Why Don't You Just Answer This Question Your Self? 25MouseSensitivity 63 — 3y
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

you didn't index character before the humanoid

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait() -- Checking if character is added

if Charcter:FindFirstChild("Humanoid") then -- Checking If there's a humanoid
    Character.Humanoid:FindFirstChild("HumanoidRootPart").Position = Vector3.new(54.86, 0.5, -77.58)
end
0
HumanoidRootPart is not a child of the Humanoid. Have you tested your code? MarkedTomato 810 — 3y
0
Changing the position of the HumanoidRootPart on the client will result in the HumanoidRootPart to be moved instead of the entire character. Use CFrame instead of position. MarkedTomato 810 — 3y

Answer this question