✓ Accepted answer
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()
local newface = Instance.new("Decal",h)
newface.Head = "Front"
newface.Name = "face"
newface.Texture = "http://www.roblox.com/asset/?id=138224650"
end)
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
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)
4 comments
Is this a Script or a LocalScript?
A local script.
Hello?
Why ask if you won't do anything.