Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why won't this script put the hat on the player? Instead the hat just falls off. (UNANSWERED)

Asked by 9 years ago
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?

0
But the problem is with the script from the other guy, ArduinoUNO, it had 2 errors in it. It can be done with multiple hats, it can stick to the player, and it does work. It works for me. Does it work in online mode? It works in solo mode. EzraNehemiah_TF2 3552 — 9y
0
Lord what hat are you using and is it a local script? Relampago1204 73 — 9y
0
I just get random hats. It is indeed local. EzraNehemiah_TF2 3552 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

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!

0
It is not working. I got the face to work but not the hat. I give up. I have asked this question for over a year to many. It just won't work. Relampago1204 73 — 9y
0
MakeJoints won't attach hats. BlueTaslem 18071 — 9y
Ad

Answer this question