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

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

Asked by 8 years ago
Edited 8 years ago

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

01                    if not v.OverlapCheck then
02                        --------------------------------------
03                        local checkforoverlap = Instance.new("Vector3Value")
04                        checkforoverlap.Parent = v
05                        checkforoverlap.Value = v.Floor.Position
06                        checkforoverlap.Name = "OverlapCheck"
07                        print("v has overlap checker")
08                        ---------------------------------------
09                        for x, overcheck in pairs(worldu:GetChildren()) do
10                            if overcheck.OverlapCheck then
11if overcheck.OverlapCheck.Value.X == v.OverlapCheck.Value.X then
12if overcheck.OverlapCheck.Value.Y < v.OverlapCheck.Value.Y then
13                                print("Overlap Found")
14                                v:Destroy()
15                            end
16                        end
17                    end
18                end
19            end
20        -------------------------------------------------
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 RobloxianDestory 262 — 8y
0
no i mean the script gives an error on the "if not v.OverlapCheck" line saying its not a valid member of model ace12345678135 50 — 8y
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. ace12345678135 50 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

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

Ad

Answer this question