I have a loop which goes through a bunch of buttons in a model and detects when they are touched, but as the title states it is failing to work properly. Here is the code:
function itemPurchasingManager(tycoonBaseplate, serverBaseplate, tycoon) for i,v in pairs(tycoonBaseplate.Buttons:GetChildren()) do v.Head.Touched:Connect(function(hit) -- Head is inside of a model which contains a humanoid and of course Head which is a part. print("Button was touched") -- this is only printing once or twice and sometimes not at all
Can someone help me? There are no if statements in front of the print so that is not the problem. I know that the script is calling the function properly. So that is not the problem either. I wonder if the touched event wont work after the for loop is done?!? Please Help!