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

Getting a part at a certain position help?

So I'm trying to get it so when you click it gets the part that is at the position of click and also only works if the parts name is defined in the table

I keep getting an error saying position is not a valid member of model at line 8

local names = {"Slab","Plate","Wall","CornerWall"}
Mouse.Button1Down:connect(function() 
	if script.Parent.Parent.MaterialPicker.Placing.Value == false then
		local WorkspaceChildren = game.Workspace:GetChildren()
		for i, v in pairs (WorkspaceChildren) do
			if v.Name == names[1] or names[2] or names[3] or names[4] then
				print("name pass")
				if v.Position == Vector3.new(Mouse.Hit.p.X, Mouse.Hit.p.Z, Mouse.Hit.p.Y) then
					print(Mouse.Hit.p.X, Mouse.Hit.p.Z, Mouse.Hit.p.Y)
				end
			end
		end		
	end
end)

2 answers

CFrame is a way you can tell your'e part in a script where to go here's a link that can tell you more about it http://wiki.roblox.com/index.php?title=CFrame Also if that doesn't work out for you try Vector3 But vector 3 is mostly used to move parts well thats what i use it for hope i helpeed :D

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