Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Getting a part at a certain position help?

Asked by
NotSoNorm 777 Moderation Voter
9 years ago

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

Log in to vote
0
Answered by 9 years ago

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

Ad
Log in to vote
0
Answered by
crut24 50
9 years ago

Did you try putting v.Position = Mouse.Hit.p ?

Answer this question