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

How to get a players torso from its player?

Asked by 6 years ago
Edited 6 years ago

How would i get a players torso? i need to teleport the player after line 22 so i need to get the character

local DefinitelyPlane = workspace:FindFirstChild("1")
local PlaneName = 1
local Plane = workspace:FindFirstChild(PlaneName)
local PositionXX = 87.18
local PlayerQuantity = 0
local Full = false

if script.Cars >= 10 then
    Full = true
end

game.Players.PlayerAdded:Connect(function(Player)
    PlayerQuantity = PlayerQuantity + 1
    if script.Cars < 10 then 
     local RPlane = Plane:Clone() 
     script.Cars = script.Cars + 1
     PlaneName = PlaneName + 1
     PositionXX = PositionXX - 15
     RPlane.Parent = workspace
     RPlane.Name = PlaneName
     RPlane:MoveTo(Vector3.new(PositionXX, 5.1, -922.8))
     print("Not Enough Players")

end
end)

1 answer

Log in to vote
-1
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

Wait for the player's character to load using the CharacterAdded event, then use WaitForChild() to grab the HumanoidRootPart of the character, and then set its CFrame to where you want to teleport them to.

local DefinitelyPlane = workspace:FindFirstChild("1")
local PlaneName = 1
local Plane = workspace:FindFirstChild(PlaneName)
local PositionXX = 87.18
local PlayerQuantity = 0
local Full = false

if script.Cars >= 10 then
    Full = true
end

game.Players.PlayerAdded:Connect(function(Player)
    PlayerQuantity = PlayerQuantity + 1
    if script.Cars < 10 then 
        local RPlane = Plane:Clone() 
        script.Cars = script.Cars + 1
        PlaneName = PlaneName + 1
        PositionXX = PositionXX - 15
        RPlane.Parent = workspace
        RPlane.Name = PlaneName
        RPlane:MoveTo(Vector3.new(PositionXX, 5.1, -922.8))
        print("Not Enough Players")
        local char = Player.Character or Player.CharacterAdded:Wait()
        local hrp = char:WaitForChild("HumanoidRootPart")
        hrp.CFrame = CFrame.new(x,y,z) --replace with the coords or the position of where you want to teleport the player
    end
end)

Ad

Answer this question