I am creating a GUI hat shop, this code is positioned inside the GUI button within frame within the GUI. The script does not throw a error but does not work either.
wait(0.5)
player = script.Parent.Parent.Parent.Parent.Parent
money = player.leaderstats.Wins
price = 0
function buy()
if money.Value >= price then
if (player:findFirstChild("Humanoid") ~= nil and debounce == true) then
debounce = false
h = Instance.new("Hat")
p = Instance.new("Part")
h.Name = "SidesweptBangsBrown"
p.Parent = h
p.Position = player:findFirstChild("Head").Position
p.Name = "Handle"
p.formFactor = script.Parent.formFactor
p.Size = Vector3.new(1, 1, 1)
p.BottomSurface = 0
p.TopSurface = 0
p.Locked = true
game.Workspace.THat1.Mesh:clone().Parent = p
h.Parent = player
h.AttachmentForward = Vector3.new(0.196, -0, -0.981)
h.AttachmentPos = Vector3.new(0.12, 0.3, -0.07)
h.AttachmentRight = Vector3.new(0.981, 0, 0.196)
h.AttachmentUp = Vector3.new(0, 1, -0)
wait(5)
debounce = true
end
end
end
script.Parent.MouseButton1Down:connect(buy)
