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

Finding all parts in a model?

Asked by
Codebot 85
8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

I'm trying to find all the bricks in the model named Mur (Wall in french). If ever an arrow is 4 studs in front of a random part in Mur, then I want the arrow to stop What I've got so far in a LocalScript located in StarterPack is this...

local plr = game.Players.LocalPlayer
local m = plr:GetMouse()
local mur = game.Workspace.Mur:GetChildren()
arrow = game.Workspace.Arrow

m.KeyDown:connect(function(key)
if key == "w" then
        for i = 1,#mur do
            print(mur[i].Name) -- Make sure all the walls are there
        --Condition Overload--
            if arrow.Looking.Value == "Up" and ((arrow.Position.Z +4) ~= mur[i].Position.X )
                 and((arrow.Position.X<mur[i].Position.X) or (arrow.Position.X>mur[i].Position.X) or (arrow.Position.X == mur[i].Position.X and (arrow.Position.Z+4) ~= mur[i].Position.Z)) then 
                        arrow.CFrame = arrow.CFrame + Vector3.new(0,0,4/#mur) -- this is where you move +4 Blocks if all the conditions are true
                        else arrow.Rotation = Vector3.new(0,0,0) arrow.Looking.Value = "Up" arrow.CFrame = arrow.CFrame + Vector3.new(0,0,0)
                end
        end
end

Answer this question