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

How do you check for an item in a model without the script giving an error?[Closed]

im trying to do a check for a value inside a for loop, the answer is most likely simple but heres what i have

the error is on the "if not v.OverlapCheck then" line. it says OverlapCheck is not a valid member of model

							if not v.OverlapCheck then
								--------------------------------------
								local checkforoverlap = Instance.new("Vector3Value")
								checkforoverlap.Parent = v
								checkforoverlap.Value = v.Floor.Position
								checkforoverlap.Name = "OverlapCheck"
								print("v has overlap checker")
								---------------------------------------
								for x, overcheck in pairs(worldu:GetChildren()) do
									if overcheck.OverlapCheck then
		if overcheck.OverlapCheck.Value.X == v.OverlapCheck.Value.X then
		if overcheck.OverlapCheck.Value.Y < v.OverlapCheck.Value.Y then
										print("Overlap Found")
										v:Destroy()
									end
								end
							end
						end
					end
				-------------------------------------------------

3 comments

0

you mean to stop the script from running until it finds the child with the name you want? you use :WaitForChild("itemnamehere") for that

0

no i mean the script gives an error on the "if not v.OverlapCheck" line saying its not a valid member of model

0

i figured it out, your answer wasnt it but it was close. it was actually FindFirstChild() post that as an answer and ill give you credit anyway.

1 answer

✓ Accepted answer

ohh. i thought you meant it didnt exist yet. which is what WaitForChild is for.

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