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

How do i add a hat on enter?

Asked by 7 years ago
Edited 7 years ago

Trying to give a player a hat when they enter the game... but it no work

local debounce = false
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
wait()

        if char:findFirstChild("Hat") == nil then
        local Hat = Instance.new("Accessory",char)
        local MeshP = Instance.new("Part",Hat)
        local Mesh = Instance.new("SpecialMesh",MeshP)      
        MeshP.Position = char.Head.Position
        Hat.Name = "Hat"
        MeshP.Name = "Handle"
        Mesh.MeshId = "rbxassetid://19326912"
        MeshP.Size = Vector3.new(1,2,2) 
        MeshP.CanCollide = true
        MeshP.Locked = true
        local Weld = Instance.new("Weld",MeshP)
        Weld.Part0 = char.Head
        Weld.C0 = char.Head.CFrame:inverse()
        Weld.Part1 = MeshP
        Weld.C1 = MeshP.CFrame:inverse()
        end
end)
end)

1 answer

Log in to vote
0
Answered by 7 years ago

you have an error with if char:findFirstChild("Hat") == nil then, its supposed to be if char:FindFirstChild("Hat") == nil then, with a captial F.

0
... That isn't and error User#13357 0 — 7y
Ad

Answer this question