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

How to check a position for a part and get the part as a variable?

I need help to this. Please if you know please tell me. And if you want to ask a question about my question then I will answer it :)

7 comments

0

What do you mean by that, check for parts that are in a Vector3 position?

0

yes

0

You could iterate through all the parts in your game and see if any of then is at the position you want to check

0

how do i do that

0

I mean in two parts, Local part = script.Parent and

0

Saficco make sure you edit the right script the one you found out.

0

Saficcio edit the new script.

2 answers

So you can get the position of the part by:

print(workspace.Position) -- This will print out the position of the part in workspace

So what you mean is if you add a vector3 position to a part you check the new position and get the part that if in that new position Here what i can do

local Part = workspace.Part -- Change this if needed
local Part2

local Target = Part.Position + Vector3.new(0,10,0)
for i,v in pairs(workspace.Model:GetChildren()) do -- Change the model name
	if v.Position == Vector3.new(Target) then
		Part2 = v
		print("Found! Yay")
	else
		print("Not Found")
	end
end

Hope this helped

3 comments

0

I mean by a part that is not a variable and the with the main part you add a vector3 position then by checking if a part is in the added position then if a part is in the position then get it as a variable

0

im trying

0

Yea the script also don't work to me :/

Brick Position

How you get a bricks position, you simply just need to get the Parts Position. This is a basic function of ROBLOX Studio.

Script

--[[Made By MillerrIAm]]--
--[Server Variables]--
local Part = script.Parent
local PartPosition = Part.Position
--[Main Script]--
print(PartPosition)

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