I have classes in my game. And I wanted tier 2 classes to require you have a certain amount of presents to play them. But no matter what I do I can never get it to work. Sometimes it will wont work and it wont give me an error so I have no clue what to do. Other times it gives me an error and doesnt work.

Heres the current code, it sets your class depending on the frame name.

local changeOutfit = game.ReplicatedStorage.ChangeOutfit
local player = game.Players.LocalPlayer

repeat wait() until
#script.Parent:GetChildren() == 2

for _, frame in pairs(script.Parent.ScrollingFrame:GetChildren()) do
	if frame:IsA("Frame") then
		frame.Button.MouseButton1Click:connect(function()
			changeOutfit:InvokeServer(frame.Name)
			script.Parent:Destroy()
		end)
	end
end

There is the code, ill also post an image where it is located in startergui.

https://imgur.com/5A0Se5o

Thank you for your time