Detecting if part exists or not

local Part = script.Parent

local MoveAmount = 10

local function MakePath(StartPos,Orientation)

local Pos = (Part.CFrame *,0,-MoveAmount/2))).Position

local Path ="Part",game.Workspace.mazepath)

Path.Anchored = true

Path.Size =,1,MoveAmount+6)

Path.Position = Pos

Path.Orientation = Orientation

Path.Name = "Path"


local function Tween(Obj,Dura,Goal)

local TS = game:GetService("TweenService")




local function MovePart(i)

local Pos = (Part.CFrame *,0,-MoveAmount))).Position

Pos =,math.round(Pos.Y),math.round(Pos.Z))

local Rotation = math.random(0,4)

Part.Orientation =,Rotation*90,0)

local StartPos = Part.Position

local NPos = (Part.CFrame *,0,-MoveAmount))).Position

local DetectCollisionRay =,NPos)

local Pt,Pn = game.Workspace:FindPartOnRay(DetectCollisionRay,Part,false,false)

if not Pt then


elseif Pt.Name == "Border" then

return false


Part.Position = (Part.CFrame *,0,-MoveAmount))).Position



while wait() do

local Var = MovePart()

if Var == false then

local Rotation = math.random(0,4)

Part.Orientation =,Rotation*90,0)




Code :arrow_double_up:

so i want my maze gen script to make it so that if a part exist then it wont place path if not it places path

Is this using a server script or a local script? I assume server

1 Like

yes its server (wow u guessed it correct)

1 Like

You can use FindFirstChild for that

Haha, sometimes new scripters don’t know the difference, I don’t know your skill level LOL.

Try using :FindFirstChild

what do you mean by that?

You see that “FindFirstChild” is blue right? Click on it and it will bring you to the api reference

i can see that but How is it suppose to help me? also there are MANY MANY parts not just one MANY

yea i am a veteran 1+ years of scripting and developing doe that wasnt a very good joke

Try working with something like this:

game.Workspace.mazepath:FindFirstChild('PART NAME HERE')

I personally learn by putting a basis of a script into the script and working with it until it works

the name is the same for all lol doe i could actually change the name :thinking:

Are they all in the same model?


Maybe create a table with the parts that it needs to make the path?

If that doesn’t work then you could model them all and use :GetDescendents then you can use if part isA(’’)

EDIT: I would try making a table and using waitforchild.

If you want to go simple then you could use a value that changes when the parts are no longer there
(I’m still trying to figure out what exactly you’re needing to do, so I’m listing things that I think could work for your purpose)

nvm i got it that how can i do it I did had a similar idea but then @michialok said FindFirstChild then you typed an example that made my brain have a pop cuz how stupid I could be LIKE I can just multiply its X Y Z with each other and that would create a UNIQUE NAME! thank you to both of you for helping

Haha, all good. Glad I could be of small assistance. Good luck.

thank you. you did helped a lot actually as you kinda reminded me how FFC works :sweat_smile: but as he gave idea so yea. Still thank you a lot and have a good day.