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

How to make a local value equal multiple parts?

So I have

local mousetarget = 

What would I put to the right of the equal sign, for it to be every brick in workspace that has a bool value in it named "Purchase" that is true?

2 answers

✓ Accepted answer

Its quite simple, you just have to iiterate through every object in workspace. and check if it have the value.

for i,v in pairs(game.Workspace:GetChildren()) do
	if v:FindFirstChild("Purchased") ~= nil then
		localMouseTarget = v
	end
end

"v" would be an object, this might not work but it should, if it doesn't try making a table and inserting v into a table.

1 comment

0

thx

There is nothing for that, there is a loop though...

for _, v in pairs(workspace:GetChildren()) do
	if v:FindFirstChild("Purchase") then
		if v.Purchase.Value == true then
			local mousetarget = v
			print(mousetarget.Name)
		end
	end
end

looping and finding purchased through all the parts then finding if its value is true then making the "mousetarget" the part...

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