Hello! I currently am working on an experimental helmet in Roblox Studio, and can’t think of a script to lock it onto a humanoid.
For example, when a player joins the game, the helmet should just be attached to them. When they move, it moves with them, when they rotate, it rotates with them. How would I achieve this?
Btw, I can not script, hence this post.
Humanoid:AddAccessory, Welds are your best options. Look them up
You could utilize the starter character folder.
Hmm, that doesn’t seem to be working. I put it in StarterPlayer, but as I assumed, that did nothing…
No, you have a pre-programmed rig (animated of course) wearing the helmet in the starter character folder. I’ll make one… give me a sec…
I mean’t I wanted it locked to the character playing, not a model.
local Helmet = -- path to helmet
game.Players.PlayerAdded:Connect(function(player) -- Listens for when the player joins
local char = player.Character or player.CharacterAdded:Wait() -- Gets the character of the player.
local hum = char:FindFirstChild("Humanoid") -- Gets their Humanoid
hum:AddAccessory(Helmet) -- Adds the helmet
end)
As @alessdai said, using Humanoid:AddAccessory should do the trick. Make sure that this script is not a local script, since AddAccessory doesn’t work on the local Client.
Nice, thanks! I will try that out in a sec.
You should make a regular script and put it in ServerScriptService, now make sure to have the right path on line 1, otherwise it won’t be able to identify the Helmet.
Oddly, it still can’t understand “Helmet”. Any further instructions?
Sorry for the late response, but it might try to look for it in the script before it loaded in ingame, did you use :WaitForChild()?
I just noticed the you used “Wait()” instead of “WaitForChild()”. I will fix that in a sec.
Ouch, it still doesn’t work. The script keeps underlining the second “Helmet”.
Edit: I fixed the underline problem, but it continues to not connect to the Humanoid.