So, I have this hat in my game, but I want to make it that everybody gets it automatically placed on their head whenever they join the game. How can I do this??
If your hat is an accessory then you can use AddAccessory() whenever a player’s character spawns.
local players = game:GetService("Players")
local hat = --directory to your accessory
players.PlayerAdded:Connect(function(player) --Fires when a player joins the game
player.CharacterAdded:Connect(function(char) --Fires when that player's character spawns
local hum = char:FindFirstChild("Humanoid")
if(hum) then
hum:AddAccessory(hat)
end
end)
end)
It isn’t an accessory, it’s just a model.
I heavily recommend using Accessories as ROBLOX already has a whole API on them — don’t try to reinvent the wheel. But if you insist on not using Accessories then you can just weld your hat’s main part to the HatAttachment in a character’s head. It’ll probably be a hassle to get the displacement right, though.
If it’s a model, then you need to weld it to the player’s HeadAttachment whenever they’re character loads, it is very inefficient to use a model when you can easily made your model into an accessory which has way more support.
Go into game settings through studio and you can set what people are wearing. You can make them wear that hat.