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

Why detect script not working with ChildAdded ?

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

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.

1 comment

0

NO

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