Im trying to make a LocalScript It fires a function if script.Parent:GetChildren() Are mouseentered but it wont work
local childs = script.Parent:GetChildren() childs.MouseEnter:connect(function() print("works") end)
Error: MouseEnter is a nil value
This is a constant loop, whenever a mouse enter any of the frames, it will print "Worked"
local children = script.Parent:GetChildren() --Returns a table of all children in a given parent for i,child in pairs(children) do -- Child is equal to every value in the children variable child.MouseEnter:connect(function() if child.ClassName == "Frame" then --If child is a frame then it prints 'Worked' print("Worked") end end) end
You should do a for function if you want all the childs to be able
for child in pairs(script.Parent:GetChildren()) childs.MouseEnter:connect(function() print("Works") end end