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

Why detect script not working with ChildAdded ?

Asked by 5 years ago

Idk what is the problem

local Stars = workspace:WaitForChild("Stars")
local StarValue = game:GetService("ReplicatedStorage"):WaitForChild("Stars")
local function Check()
    for _, thing in pairs(Stars:GetChildren()) do
        if thing.ClassName == "Model" then
            for __, Star in pairs(thing:GetChildren()) do
                if Star.ClassName == "UnionOperation" then
                    StarValue.Value = StarValue.Value +1
                    print(StarValue.Value)
                end
            end
        end
    end
end

Stars.ChildAdded:Connect(function(m)
    if m:IsA("Model") then
        Check()
    end
end)

1 answer

Log in to vote
0
Answered by 5 years ago
Stars.ChildAdded:Connect(function(m)
    wait()
    if m:IsA("Model") then
        Check()
    end
end)

Also you use .ClassName and :IsA() its not syntactically incorrect but it just makes the code look bad.

0
NO FrezeTagger 75 — 5y
Ad

Answer this question