I have a question. help me

Players in the workspace with humanoid

I understand that it’s different to be located in Game.Player

I want access to a player whose class name is a model underneath the workspace, but it’s not working

Is the player inaccessible in a workspace other than game.player?

for example

local user = workspace:FindFirstChildOfClass(“Model”)

1 Like

Listen, Stop making more posts about the same topic, you are going to be banned. Delete this one and go back to the other one.

1 Like

To access the player from game.Players via workspace, you can use:

local user = workspace:FindFirstChildOfClass(“Model”)
 game.Players:GetPlayerFromCharacter(user)

I am not entirely sure if this is what you meant but i hope this helps.

2 Likes

That’s going to find the first model in the game, not specifically the player? And even if it finds a player, it won’t be a specific one, it will be the first one it finds.

You can access the player from the workspace. You just have to have a way to either loop through all of them or uniquely find a player. Usually if you have to find the character from workspace you are probably doing something wrong.

Like I could do game.Workspace.tlr22 to get my own character (assuming I’ve already spawned). But if I search for the first model I might get my friends model, or I might get the model that is a building.

My question is how do you know what character you are trying to find? The answer to that will be how you learn to search for it.

I mean I guess you could do something like this

task.wait(2)
local workspaceParts = game.Workspace:GetDescendants()--[[So we can loop through the workspace later]]
local playerTable = {}
local players = game:GetService("Players")

players.PlayerAdded:Connect(function() do --[[Every time a player joins it executes code]]
                task.wait(5)--[[To let the player load in]]
		for i, v in pairs(workspaceParts) do
			if v:IsA("BasePart") and v.Name == "HumanoidRootPart" and v.Parent ~= game.Workspace.Noob --[[Or just any npc you want to ignore]] then
				local playerName = v.Parent.Name
				table.insert(playerTable, playerName)
			end
		end
	end
end)

But like, I don’t get why you’d even want to do this, PlayerAdded gives the player that was added as information, which you can use to access any parts you need, humanoid, humanoidrootparts, there are a ton of better ways to do this, also this may not work i didn’t test it.