What do you want to achieve? Keep it simple and clear!
Trying to make a system where on death you equip a randomized hat from a folder
What is the issue? Include screenshots / videos if possible!
Getting the hat to parent under the character doesn’t work.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried to use :AddAccessory and parenting normally along with using .CharacterAdded. Every time it produces the same result (printing works, no hat)
local Players = game:GetService('Players')
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild('Humanoid')
local RepStorage = game:GetService("ReplicatedStorage")
local Accessories = RepStorage.Accessories
local hats = Accessories.team1.Hats:GetChildren()
local function gethats()
local hat = hats[math.random(1, #hats)]
local newhat = hat:Clone()
newhat.Parent = Character
end
local function HumanoidDied()
print(('Player %s died!'):format(Player.Name))
gethats()
end
Humanoid.Died:Connect(HumanoidDied)
Well, from the script you’ve sent, the hat is added to the player when it dies, but when a player dies, all joints in the character are broken, you could try disabling BreakJointsOnDeath property inside of Humanoid and work from there or create new joints and attach your hats that way.