game.Players.PlayerAdded:connect(function(player) player.CanLoadCharacterAppearance = false local characterArmour = script["Grim Reaper"] if characterArmour then player.CharacterAdded:connect(function(character) if character then for _, v in pairs(characterArmour:GetChildren()) do if v.Name == "Handle" then local handle = v:Clone() local accessory = Instance.new("Accessory", character) handle.Parent = accessory handle.FormFactor = "Custom" handle.Size = Vector3.new(2, 1, 1) accessory.AttachmentPos = Vector3.new(0, 0.5, 0) handle.Anchored = false end end end end) end end)
I'm trying to get a part to be attached to the players head, like a hat. The only problem I have is when I change the handle to something else, it changes how it's placed on the character. How can I make it so it always put the handle on the players head as if it were a normal hat?
EDIT Images
Instead of over-complicating things, you should instead use InsertService
.
This will take the accessory straight from the catalog and right into the player. The script would look a little bit like this.
game.Players.PlayerAdded:connect(function(p) repeat wait() until p.Character -- (WAITING FOR CHARACTER) local hatId = 28276664 -- Change to whatever you want it to be local insertService = game:GetService("InsertService") -- Getting insertService insertService:LoadAsset(hatId):GetChildren()[1].Parent = p.Character -- Loading it into the character end)
The script above works because it's getting the accessory and placing it straight into the character. The accessory already comes with all the positioning, so all you really need to do is that.
If you want to insert multiple hats at the same time, you can do so like this
local hats = {11748356,1235488,124730194} -- Accessories IDS go in here game.Players.PlayerAdded:connect(function(p) repeat wait() until p.Character -- (WAITING FOR CHARACTER) local insertService = game:GetService("InsertService") -- Getting insertService for i,v in pairs(hats) do insertService:LoadAsset(v):GetChildren()[1].Parent = p.Character -- Loading in the hats end end)
For a custom hat, you would need the hat to be somewhere in the game, and cloning it right into the player
game.Players.PlayerAdded:connect(function(p) repeat wait() until p.Character -- (WAITING FOR CHARACTER) script:WaitForChild("ClockworksShadesYellow"):Clone().Parent = p.Character -- Cloning hat into the player end)
The hat as you can see is already inside the script, so we're just cloning it.
And it all works, perfectly PLAYER WITH THE CUSTOM HAT