p = game.Players.LocalPlayer char = p.Character Storage = game:GetService("ServerStorage") --Using :GetService() because the script can cause an error if used in multiplayer(uploaded to roblox) when not calling the service script.Parent.MouseButton1Down:connect(function() local cont = char:GetChildren() for i,v in pairs(cont) do -- Removing all other hats if v:IsA("Hat") then v:Destroy() end end local hat = Storage.HATNAME:clone() --HATNAME is just a template for other hats in serverstorage hat.Parent = char hat.Name = "Hat" end) --Also how could this be done with multiple hats?
I already Answered this question here. Look at the edit section.
player = game.Players.LocalPlayer h = player.Character.Head script.Parent.MouseButton1Down:connect(function() if not h.face.Texture == "http://www.roblox.com/asset/?id=138224650" then h.face:Destroy() for _,v in pairs(player.Character:GetChildren()) do --Get all the children if v.ClassName == "Hat" then --If it's a hat v:Destroy() --Destroy for _,i in pairs(game.ServerStorage:GetChildren()) do --Get all the hats in serverstorage. if i.ClassName == "Hat" then i:clone().Parent = player.Character --Make the hat's go inside the character player.Character:MakeJoints() --MAKE JOINTS!!! end end end end local newface = Instance.new("Decal",h) newface.Name = "face" newface.Texture = "http://www.roblox.com/asset/?id=138224650" end end)
I told you to make joints! Use the :MakeJoints()
function! Use this function to make the hat stay on your head!