Help with getting the character from PlayersService

  1. What do you want to achieve?
    Im making a round system for my game, and when a round starts, i want to teleport them to a block, and for that i need to be finding the HumanoidRootPart, and for that i need to get the Character, and i cant seem to get it from the PlayersService
  2. What is the issue? Include screenshots / videos if possible!
    I cant find a way to get the character
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have looked in some posts but their scripts were all different from mines.

To make this easier, here is the uncompleted version of my round system, i added a comment on the function i need help with

local lobbytp = game.Workspace.lobby
local rallytp = game.Workspace.lobby
local plrs = game:GetService("Players")

local function countPlayers()
	local req = 1 -- amount of required plrs to start
	_G.signal = false
	
	if #plrs:GetChildren() >= req then -- if there is more than 2 plrs, send signal telling to start
		_G.signal = true
	end
	--[[if #plrs:GetChildren() < req then
		_G.signal = false
	end]]
	
end
wait(10)
countPlayers()
print(_G.signal)
local function RoundStart()
	if _G.signal == true then
		for amount, item in pairs(plrs:GetChildren()) do
			local gui = item:WaitForChild("PlayerGui")
			local label = gui.TopLabel.TextLabel
			local IntTime = 30
			
			for i = 1, 30 do
				IntTime = IntTime - 1
				label.Text = "Starting in " ..IntTime
				wait(1)
			end
			if IntTime == 0 then
				label.Text = "Starting the game... "
				wait(1)
			end
		end
	else
		for amount, item in pairs(plrs:GetChildren()) do
			local gui = item:WaitForChild("PlayerGui")
			local label = gui.TopLabel.TextLabel
			
			label.Text = "Need more players to start (2 minimum)"
		end
	end
end

local function TP()
	local plrs2 = plrs:GetChildren()
	local character = plrs.CharacterAdded-- i cant figure out this part

end

coroutine.wrap(RoundStart)
local character = plrs.Character
1 Like

Or character = plrs.CharacterAdded:Wait()

1 Like

Ive tried those and they didnt work, gave me an error

1 Like

Can u tell the error? Idk what could be the error

Make an array like this:

local characters = {}

Now you need to loop through all the players and add their characters into the list

for i, plr in pairs(plrs2) do
   table. Insert(characters,plr.Character)
end

Optionally you could just tp them one by one like this

for i,plr in pairs(plrs2) do
   plr.Character.HumanoidRootPart.CFrame = workspace.Lobby.SpawnLocation.CFrame -- Change this to your location
end

The thing is, you cant get the character from players service since the service doesn’t have a character child, but the player does. And since players service can give you a table of players, use that to get the players

3 Likes

Thank you, ill give it a try. character limit aaaaaaaaaaaaaaaaa

Thanks a lot! It worked :smiley: character limit again!?

Forgive me if Im a bit dumb here (im quite so), but wdym by character limit?

Oh its because you need to write a minimum of 30 words to reply

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.