of     1   

Club24Hour
#140572051Thursday, July 17, 2014 12:36 AM GMT

for index, child in pairs(script.Parent.Hats:getChildren()) do local hatId = child.id function onClick() print(3) local player = game.Players.LocalPlayer Game:GetService("MarketplaceService"):PromptPurchase(player, hatId) child.ImageButton.MouseButton1Click:connect(onClick) end end
Club24Hour
#140572329Thursday, July 17, 2014 12:39 AM GMT

bump
MHebes
#140572342Thursday, July 17, 2014 12:39 AM GMT

You connected the function within the function itself. If you indent your code, it becomes clear. Check out this codepad: /eEuTCz5i Just move the connection after the first end.
maxomega3
#140572363Thursday, July 17, 2014 12:39 AM GMT

If it looks good, what's wrong with it?
Notunknown99
#140572383Thursday, July 17, 2014 12:39 AM GMT

Is hatId an Instance or int?
LUVMARIOLUIGI10000
#140572513Thursday, July 17, 2014 12:41 AM GMT

"No error, but looks good.." Sorry, but this code is just horrific. I assume you want to promt a purchase when the player clicks the gui? local Player = Game:GetService('Players').LocalPlayer; for i,v in next, script.Parent.Hats:GetChildren() do v.ImageButton.MouseButton1Click:connect(function() Game:GetService('MarketplaceService'):PromptPurchase(player, v.id) end) end -- This should work.
maxomega3
#140572608Thursday, July 17, 2014 12:42 AM GMT

Yeah, functions only fire went a connected event happens. If you put the connection line in the function, the engine will never read it. here's a visual: -- this is the code function lol () print ('Hello World!') end lol () -- but this is how the computer will read it lol () -- Great, now I gotta find out what this means function lol () -- here we are! print ('Hello World!') -- now this will execute end
LUVMARIOLUIGI10000
#140573011Thursday, July 17, 2014 12:46 AM GMT

@max - You can have a connection line within a function and it will fire every time as long as you call the function. Ex: local Hi = function() Game:GetService('RunService').Stepped:connect(function() print'hi' end) end Hi()
Club24Hour
#140583692Thursday, July 17, 2014 2:33 AM GMT

It says there is an error line 6, unable to cast int
Club24Hour
#140585086Thursday, July 17, 2014 2:46 AM GMT

21:45:41.444 - Unable to cast Instance to int

    of     1