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

Something went wrong?

Asked by 9 years ago

Hello, I recently had help with this click hat giver but one thing remains, the part doesn't stay on the player, as if it does not remain as a Handle. Once you click it appears on your head then falls off? What might be the problem with this script?

if not ClickDetector then
    ClickDetector = Instance.new("ClickDetector", script.Parent)

end

ClickDetector.MouseClick:connect(function(Player)

    local Character = Player.Character
    if Character and Character:FindFirstChild("Humanoid") and debounce and Character:FindFirstChild("Head") then
        debounce = false
        h = Instance.new("Hat", Character)
        p = Instance.new("Part", h)
        h.Name = "Hat"
        p.Position = Character.Head.Position
        p.Name = "Handle"
        p.FormFactor = 0

        p.Size = Vector3.new(0, 0, -1)
        p.BottomSurface = 0
        p.TopSurface = 0
        p.Locked = true
        script.Parent.Mesh:Clone().Parent = p

        h.AttachmentPos = Vector3.new(0,0.4,-0.025)
        wait(5)
        debounce = true
    end
end)

Answer this question