so I updated your script to fit my needs, but it does not position on the head it shows up somewhere else
Try using Humanoid:AddAccessory(accessory)
, where accessory
is your hat’s handle parented to the accessory object. Don’t forget about adding attachments to the hat.
well I am trying to add a model to the player not an accessory
Aha, then you should do the same thing as @goldenstein64 previously mentioned.
To do this, weld all parts to a root of the hat. Then proceed doing the same thing. If it doesn’t work, the hat is missing attachments.
Could you screenshot what the hierarchy of your hat model looks like? I’m theorizing you could just switch the model instance out for an accessory instance and it would still be the same hat, then you could just use @anon81993163’s method.
oh that is what I forgot guys the attachments, oops thanks for your help I am gonna test it out after I add the attachments
quick question how do you add an attachment, sorry
nvm thanks for your help guys I am gonna test it out
how many attachments would you need for the hat, would it depend on the amount of parts you have inside the model because it still does not attach to the face?
You only need one attachment, which should correspond to one of the attachments on the head(or body).
Attachments can be added through the model tab, where you can create ropes, rods and other constraints.
Just use accessories and attachments. Your hat is automatically positioned according to where the attachment is, as attachments are lined up. If you’re editing in Studio, changing the position of the attachment actually changes the position of the item being welded since accessory welds are rigid.
If you absolutely need to weld a model, the easiest way is to make an invisible clone of a limb, weld your parts to that and then weld the pseudo limb to the real limb. Use WeldConstraints. You use an extra instance but I prefer this over trying to figure out positions with math.
Here are some screenshots, sorry it took so long
how would you connect a weld constraint to something using a script?
Literally just weld everything in your model and put it into your accessory. From there you can position it accordingly.
Keep in mind that I find accessories are often extremely glitchy when it comes to position. It’s not uncommon for your entire model to glitch out when parented to a character. This could be why you’re having unwanted results.
Now I have this problem, 19:40:16.240 - Workspace.HatGiver:10: bad argument #3 to ‘Part0’ (Object expected, got CFrame)
Can you show me the code causing this error?
Here is my script:
game:GetService("Players").PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(plr)
game.ReplicatedStorage.Hat.OnServerEvent:Connect(function()
local clone = game.ServerStorage.Handle:Clone()
clone.Parent = plr
local Part = game.ServerStorage.Handle.rootpart
Part.Position = plr.Head.Position
local newWeld = Instance.new("WeldConstraint")
newWeld.Parent = workspace
newWeld.Part0 = Part.FaceCenterAttachment.CFrame
newWeld.Part1 = plr.Head.HatAttachment.CFrame
print("Success")
end)
end)
end)
Sorry for the late response. That’s not what I meant when I told you to weld everything. You need to weld all the parts in the model together first. Then, you can use AddAccessory() to make your character wear the whole model.
Also for future reference, the Part0 and Part1 properties of WeldConstraints should be parts, not CFrame vales.
ok thanks for that I will let you know if I have any problems
it also says that it has to be a valid accessory (but I think I figured it out) Thanks!
Here is an article that helps: