So I tried to minimize my script with i,v loops. But then I did that the MouseButton1Click function
doesn’t fire. Here is the script:
for i,v in pairs(workspace.Shop.Board.SurfaceGui.SongFrame:GetChildren()) do
if v:IsA("ImageButton") then
print(v)
v.MouseButton1Click:Connect(function() --*here*
print(v)
if game.Players.LocalPlayer.stats.Level.Value >= v.Values.Level.Value then
print(v)
workspace.MusicFolder:ClearAllChildren("Sound")
local musicCreate = Instance.new("Sound",workspace:FindFirstChild("MusicFolder"))
musicCreate.SoundId = v.Values.Music.Value
musicCreate.Looped = true
else
print(v)
local haha = game.ReplicatedStorage.LowLevel:Clone()
haha.Parent = player.PlayerGui
haha.TextFrame.Text.Text = "You need to be in level " .. workspace.Shop.Board.SurfaceGui.SongFrame.PlayFrame4.Values.Level.Value .. " To play this piece!"
haha.TextFrame.Text:TweenSize(UDim2.new(1, 0, 0.71, 0))
wait(2.1)
haha.TextFrame.Text:TweenSize(UDim2.new(0, 0, 0, 0))
wait(1)
haha:Destroy()
end
end)
end
end