Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Automatic Hat positioning - Possible or not?

NOTE: This is NOT a request

I'm going to start with a snippet of my code:

-- Code stuff above

local Hat= Player.Character:WaitForChild("Hat")
local MeshTexture = {1132299978, 29713290, 657550801, 161220362, 15393013}
local MeshsMesh= {1132299682, 29713297, 135444151, 161220260, 15393031}

local count = 1
local char = Player.Character
local Mesh = Shirt.Handle.Mesh

function Update()
    Mesh.MeshId = "rbxassetid://"..MeshsMesh[count]
	Mesh.TextureId = "rbxassetid://"..MeshTexture [count]
	Hat.Handle.CFrame = char.Head.CFrame * CFrame.new(0, char.Head.Size.Y / 2, 0) * Hat.AttachmentPoint:inverse()
end

-- Code stuff below

So, basically I'm creating a character customisation script, which works fine. However, I'm attempting to see if there's a way to automatically set a position of a hat. The code I'm using for that is this:

Hat.Handle.CFrame = char.Head.CFrame * CFrame.new(0, char.Head.Size.Y / 2, 0) * Hat.AttachmentPoint:inverse()

But it only works with some hats, so I've been trying for the past hour or so to find out if it's possible. If it is possible, could you please tell me and give me a nudge in the right direction.

EDIT: Just to make it clear, there is already an accessory created using a server script.

3 comments

0

The script itself is fine, it's just the hat positioning script.

0

Instead of adding accessories manually, try using Humanoid:AddAccessory() http://wiki.roblox.com/index.php?title=API:Class/Humanoid/AddAccessory

0

Mmk, I'll check it out

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.