Help With Hat Giving Script

Hi! If you are reading this help would be appreciated! Basically what I want is when a player joins a game, they get a random accessory. I already know how to do the random part of the script but I do not know how to give each player in the server a certain hat. How would I do this?

This is what I have so far…

inserver = {}

game.Players.PlayerAdded:connect(function(person)
	table.insert(inserver, person.Name)
	print(person.Name)
	person.Hat.MeshId = "http://www.roblox.com/asset?id=71483350"
end)

You cannot modify a MeshPart’s MeshId shown here.

How would I change the hat mesh then?

if you store your hats in a table, you can go and look for “table.find” and look for hat name, then try to clone it and attach the hat to the player head (person.Character:FindFirstChild(“Head”)

I recommend you to store random assets into a table and check for them, and give a random asset to the player who joined the game.

1 Like

You need to make a new Hat every time. Just to be sure, are you using a MeshPart as a Hat or you are using a Hat instance to do this?

Im using an Accessory with a handle and a mesh part.