Use .ChildAdded
local parentObject = yourparentobjecthere
local wantedChild = whatyouwantittobe -- you could use the name instead
parentObject.ChildAdded:Connect(function(child)
if child == wantedChild then -- to use name do if child.Name == wantedChild.Name then
-- stuff here
end
end)
4 Likes
Do you know why Roblox uses :
and .
for functions? What’s the difference?
object.ChildAdded:Connect(function()
. is for an event, so the event child added connects a function. Child added is not a function itself.
the :connect is for connecting a function
alternatively you could use
function what()
print("what the a")
end)
object.ChildAdded:Connect(what) -- notice the dot before child added and the colon before connect
sory if i dont explain clearly
2 Likes