I have a buying system. A player buys a cart, for every cart they purchase, then a ImageButton is created in a ScrollingFrame with a UIGridLayout. I'm assuming my problem is that the pairs function is grabbing the ImageButtons when the script initially runs. There is no image buttons in the scrolling frame until a player buys a cart in-game. I'm not sure a way around that. Here's my script,
game.Players.LocalPlayer:WaitForChild("PlayerGui")
game.ReplicatedStorage.RemoteEvents.updatePlayerCarts:FireServer()
mcstatus = false
mcdb = false
script.Parent.myCartsButton.MouseButton1Down:connect(function()
if mcstatus == false and mcdb == false then
mcdb = true
script.Parent.myCarts:TweenPosition(UDim2.new(.1,0,.2,0))
script.Parent.myCartslabel:TweenPosition(UDim2.new(.1,0,.135,0))
wait(1.2)
mcstatus = true
mcdb = false
elseif mcstatus == true and mcdb == false then
mcdb = true
script.Parent.myCarts:TweenPosition(UDim2.new(1.1,0,.2,0))
script.Parent.myCartslabel:TweenPosition(UDim2.new(1.1,0,.135,0))
wait(1.2)
mcstatus = false
mcdb = false
end
end)
for i,v in pairs(script.Parent.myCarts:GetChildren()) do
if v:IsA("ImageButton") then
v.MouseButton1Down:connect(function()
print("Working!")
end)
end
end
Thanks for anyone who helps me.
