Hi.
I want to make a multicolored baseball cap, but I have multiple parts for the cap. I currently have two problems; I do not know how to make the cap have multiple parts that all attach in the right places, and the main part of the cap does not attach correctly:
I want the cap to move slightly upwards and also have the logo be rotated towards the front. (Currently it is on the left side of the player.)
Is there any way I can “weld” all of the meshes together in one part so that this script works?
debounce = true
function onTouched(hit)
if (hit.Parent:findFirstChild("Humanoid") ~= nil and debounce == true) then
debounce = false
local h = Instance.new("Hat")
local p = Instance.new("Part")
h.Name = "NoobHat"
p.Parent = h
p.Position = hit.Parent:findFirstChild("Head").Position
p.Name = "Handle"
p.formFactor = 0
p.Size = Vector3.new(0.108, 0.026, 0.053)
p.Orientation = Vector3.new(0, 0, 0)
p.BottomSurface = 0
p.TopSurface = 0
p.Locked = true
script.Parent.Mesh:clone().Parent = p
h.Parent = hit.Parent
h.AttachmentForward = Vector3.new (-0, -0, -1)
h.AttachmentPos = Vector3.new(0, 0.092, 0)
h.AttachmentRight = Vector3.new (1, 0, 0)
h.AttachmentUp = Vector3.new (0, 5, 0)
wait(5)
debounce = true
end
end
script.Parent.Touched:connect(onTouched)
Thanks in advance!
NimaDev
(Nima)
July 6, 2022, 3:24pm
#2
You can use Accessory, its the way to do it and it’s pretty simple to use here
Is there any way to attach all of the hat parts like so?
You can weld them, and fix the position from there
debounce = true
function onTouched(hit)
if (hit.Parent:findFirstChild("Humanoid") ~= nil and debounce == true) then
debounce = false
local h = Instance.new("Accessory")
local p = Instance.new("Part")
h.Name = "ClemsonHat"
p.Parent = h
p.Position = hit.Parent:findFirstChild("Head").Position + Vector3.new(0, 10, 0)
p.Name = "Handle"
p.formFactor = 0
p.Size = Vector3.new(0.108, 0.026, 0.053)
p.Orientation = Vector3.new(0, 0, 0)
p.BottomSurface = 0
p.TopSurface = 0
p.Locked = true
script.Parent.Mesh:clone().Parent = p
h.Parent = hit.Parent
h.AttachmentForward = Vector3.new (-0, -0, -1)
h.AttachmentPos = Vector3.new(0, 0.092, 0)
h.AttachmentRight = Vector3.new (1, 0, 0)
h.AttachmentUp = Vector3.new (0, 5, 0)
wait(5)
debounce = true
end
end
script.Parent.Touched:connect(onTouched)
I tried this script to try and move the hat up, is there any way I can fix it?
Yeah, basically you just mess around with the numbers here to fix the position to your liking.
h.AttachmentForward = Vector3.new (-0, -0, -1)
h.AttachmentPos = Vector3.new(0, 0.092, 0)
h.AttachmentRight = Vector3.new (1, 0, 0)
h.AttachmentUp = Vector3.new (0, 5, 0)
I adjusted this to (0,100,0) and nothing changed. Another problem; the color of the hat changes back to grey when I equip it.
Using the Humanoid:AddAccessory()
will give an accurate result also must have an attachment called HatAttachment
, this only works on server script, local script also works but does not position the hat.
The hat seems to use only 1 material maybe try using unions???
It is a MeshPart not a normal part.
NimaDev
(Nima)
July 6, 2022, 9:00pm
#11
Sorry for late response,
just name one of the parts/mesh ‘Handle’ which will be the main part of your accessory then attach all the other parts to the main part/mesh as shown in the image below, after that you need to add a Attachment to adjust the Accessory position on the character.
Note: Make sure the parts are NOT anchored.
Here is my setup; the script is the same as above.