Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function handleHat(hat)
- local head = script.Parent:WaitForChild("Head")
- local handle = hat:WaitForChild("Handle")
- local newWeld = Instance.new("Weld",handle)
- newWeld.Name = "AttachHat"
- newWeld.Part0 = head
- newWeld.Part1 = handle
- newWeld.C0 = hat.AttachmentPoint:inverse() * CFrame.new(0,0.5,0)
- handle.Parent = head.Parent
- handle.Name = hat.Name
- hat:Destroy()
- end
- function onPlayerEntered(player)
- local function onCharacterAdded(char)
- char.ChildAdded:connect(function (child)
- if child:IsA("Hat") then
- handleHat(child)
- end
- end)
- end
- if player.Character then
- onCharacterAdded(player.Character)
- end
- player.CharacterAdded:connect(onCharacterAdded)
- end
- game.Players.PlayerAdded:connect(onPlayerEntered)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement