Local script
script.Parent.MouseButton1Click:connect(function()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local createPartEvent = ReplicatedStorage:WaitForChild("GiveHatAfro")
createPartEvent:FireServer()
end)
Receiver
local re = Instance.new("RemoteEvent",game.ReplicatedStorage)
re.Name = "GiveHatAfro"
re.OnServerEvent:Connect(function(Player)
Player.hats.Money.Value = 1
Player.hats.Money2.Value = 0
Player.hats.Money3.Value = 0
Player.hats.Money4.Value = 0
Player.hats.Money5.Value = 0
Player.hats.Money6.Value = 0
Player.hats.Money18.Value = 0
Player.hats.Money19.Value = 0
Player.hats.Money20.Value = 0
local character = Player.Character
local d = character:GetChildren()
for i=1, #d do
if (d[i].className == "Accessory") then
d[i]:remove()
end
end
if character:findFirstChild("Humanoid") ~= nil then
h = Instance.new("Accessory")
p = Instance.new("Part")
h.Name = "Hat"
p.Parent = h
p.Position = character:findFirstChild("Head").Position
p.Name = "Handle"
p.formFactor = 0
p.Size = Vector3.new(-0,-0,-1)
p.BottomSurface = 0
p.TopSurface = 0
p.Locked = true
script.Mesh:clone().Parent = p
h.Parent = character
print("SUCCESS")
h.AttachmentPos = Vector3.new(0, -0.20, 0)
wait(.1)
end
end
end)
