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 a players torso from its player?

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

✓ Accepted answer

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)

1 comment

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