Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I get every single part in workspace?

I was thinking of getting all the parts with a class name of Part, meshpart, wedge etc.Maybe even tracking all the descendants. Also thinking of adding for loops into all the models, but that sounds a little too troublesome if you ask me. Is there any easier, more efficient ways for me to get every single part in the workspace? Maybe something detecting the mouse target and automatically turning the target filter to them

1 answer

To return every child of workspace, you use the GetChildren method.

for _,v in pairs(workspace:GetChildren()) do
	if v:IsA("BasePart") then
		print(v.Name)
	end
end

Assuming I understood the final portion of your question, you would use the GetMouse method in a LocalScript.

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local tar = mouse.Target

mouse.Move:connect(function()
	print(tar)
end)

1 comment

0

Your second code block would not work because 'tar' is a fixed value. Set 'tar' inside the callback so it updates every time the callback runs.

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