So this is what my script is.
I keep getting this error that says Players.Player.PlayerGui.Menu.Frame.Hats.LocalScript:18: bad argument #1 to 'random' (interval is empty)
local hats =
{
Spikey = {Name="Spikey",Location=game:GetService("ReplicatedStorage"):WaitForChild("Ultra-Fabulous Hair")};
Cowlick = {Name="Front Cowlick",Location=game:GetService("ReplicatedStorage"):WaitForChild("FrontCowlick")};
}
local Dummy = workspace:WaitForChild("Dummy");
local Parent = script.Parent;
local Last = Parent:WaitForChild("Last");
local Next = Parent:WaitForChild("Next");
local HatName = Parent:WaitForChild("HatName");
Next.MouseButton1Click:connect(function()
for i,v in pairs(Dummy:GetChildren()) do
if v:IsA("Hat") then
v:remove()
end
end
local newhat = math.random(#hats);
local newhatc = hats[newhat];
newhatc.Location:Clone().Parent = Dummy;
HatName.Text = newhatc.Name
end)

2 comments
It may not be 100% correct, but my guess might be to change math.random(#hats) to math.random(1,#hats)
that didnt work either