Can't find the players HumanoidRootPart in workspace?!

Hello DevForum,

  1. What do you want to achieve? Keep it simple and clear!
    I want to make teleportation between the Lobby and to the map for all the players in a different location. I made on every map 6 parts where people can spawn (The size of a full lobby).

  2. What is the issue? Include screenshots / videos if possible!

Now i have this script:

wait(loadTime)
	spawn(function()
		for _,plr in pairs(gamePlayers:GetPlayers()) do
			local spawnChoose = mapSpawn.Spawns:GetChildren()
			local char = game.Workspace.plr
			local Humanoid = char.HumanoidRootPart
			Humanoid.Position = spawnChoose

And mapSpawn is a local variable that clones 1 of the 3 maps.
But I can’t find the player in the 5th line of code because of game.Workspace.plr is not a valid member of the workspace. I thought that every single time the loop goes through the player plr is the username of the player he is looping through.

How can I find, with this script the HumanoidRootPart for every player the IV in Pairs is looping through?
Can someone help me with this?

Regards,
JailBreak2007_1

Instead of indexing the workspace for the player, you should use the .Character property instead.

local char = plr.Character

As for why your script didn’t work, that’s because it’s searching for a child named “plr” in the workspace, not the value of the plr variable. If you wanted to do that instead, you have to use square brackets.

local char = game.Workspace[plr.Name]
1 Like

O i am so dumb :joy: i could know this lol