player = game.Players.LocalPlayer h = player.Character script.Parent.MouseButton1Down:connect(function() h.face:Destroy() wait(0.01) newface = Instance.new("Decal",h) newface.Head = "Front" newface.Name = "face" newface.Texture = "http://www.roblox.com/asset/?id=138224650" end
When I select on the gui the players face is not removed.
The problem is h
. Variable h is the character. Not the head that the face is it. You also need a )
after the end
. This is because the function is in the connect. This is a shorter way to write event scripts but you need the )
. So basicly you just need to close the parentheses. Here this is better:
player = game.Players.LocalPlayer h = player.Character.Head script.Parent.MouseButton1Down:connect(function() h.face:Destroy() --No wait needed. local newface = Instance.new("Decal",h) newface.Head = "Front" newface.Name = "face" newface.Texture = "http://www.roblox.com/asset/?id=138224650" end) --You need the ")" because of line 3.
Hat:
player = game.Players.LocalPlayer h = player.Character.Head script.Parent.MouseButton1Down:connect(function() h.face:Destroy() for _,v in pairs(player.Character:GetChildren()) do if v.ClassName == "Hat" then v:Destroy() game.ServerStorage.Hat:clone().Parent = player.Character --Put the hat in ServerStorage and name it "Hat". end end local newface = Instance.new("Decal",h) newface.Name = "face" newface.Texture = "http://www.roblox.com/asset/?id=138224650" end)
EDIT:
For multiple hats and this is both of the scripts combined
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 if v.ClassName == "Hat" then v:Destroy() for _,i in pairs(game.ServerStorage:GetChildren()) do i:clone().Parent = player.Character player.Character:MakeJoints() end end end local newface = Instance.new("Decal",h) newface.Name = "face" newface.Texture = "http://www.roblox.com/asset/?id=138224650" end end)
Hats:
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() --Change HATNAME to the name of the hat and put the hat in ServerStorage hat.Parent = char hat.Name = "Hat" --If the hat is not anchored in ServerStorage it should appear on your head. end)