Randomized Accessories

get sum from roblox studio to get hat models then make ur own folder

I hate to say this but it doesn’t work, this isn’t really a big thing for my project so I’ll just mark this as solved because I feel as if this is impossible to achieve.

no no no no just explain the issue.

Check mine pls I’d like to see if it works for u

Everything is possible! Even from our imagination.

So what issue is it?

  1. Hats are still duplicates on characters?
  2. Player has multiple hats?
  3. Any errors?

Okay, here is an image just now using the script you made

I don’t want the players to have a mess of hats, I just want them to have one hat, also options 1 and 2, there are no errors, so we don’t need to worry about that.

local Hats = game:GetService(‘ReplicatedStorage’):FindFirstChild(‘CharacterAssets’):FindFirstChild(‘Hats’):GetChildren()

if Player then
local Character = Player.Character or Player.CharacterAdded:Wait()

	local randomHat = math.random(1,#Hats)
	local Chosen = Hats[randomHat]:Clone()

	Chosen.Parent = Character:FindFirstChild('Head')

The issue in your script is that you don’t delete it from server storage etc. You are duplicating the item.

Looks to me like you’re setting the hat for the StarterCharacter model instead of each player’s character. You could try to set the player’s character’s hats when they spawn in like this

local ServerStorage = game:GetService("ServerStorage")

	if player.Character then
		local Hats = ServerStorage.CharacterAssets:WaitForChild("Hats"):GetChildren()
		local Hat = Hats[math.random(1, #Hats)]
		Hat.Parent = player.Character
		local Hats = ServerStorage.CharacterAssets:WaitForChild("Hats"):GetChildren()
		local Hat = Hats[math.random(1, #Hats)]
		Hat.Parent = char

Luck can’t be decided it’d be best to clone it so others can have that hat

Yeah this one works exactly how I’d imagine it to work, thank you so much, and I’m very sorry for wasting everyones time on this.


But he didn’t even want to others have the same hat…

1 Like

Nah it was nice to to break my head a bit. I think i got my code like 10 seconds later oh well :face_with_peeking_eye:

1 Like

You’re welcome. Glad I could help!


“it doesn’t matter if two players have the same hat”

first read the full post before trying to correct him thanks.

1 Like


Need anything else man?

1 Like

I’m get how I sound here but I’d imagine stating it as the quote says would be the most reliable source on what he want’s as it’s the most recent

I’m not here to argue