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 7 years ago
Edited 7 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

                            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
                -------------------------------------------------
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 — 7y
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 — 7y
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 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago

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

Ad

Answer this question