How my code is supposed to work is a hat is cloned and the handle’s size is changed to match the player’s size. Here is my current code:
function module.equipunequip(player,state,hat)
if state == "Unequip" then
hat.Value = false
hat:WaitForChild("Object").Value:Destroy()
hat:WaitForChild("Object"):Destroy()
elseif state == "Equip" then
hat.Value = true
local clone = game.ServerStorage:WaitForChild("Hats"):WaitForChild(hat.Name):Clone()
clone.Name = hat.Name
clone.Handle.Size = player.Size.Value
local object = Instance.new("ObjectValue",hat)
object.Name = "Object"
object.Value = clone
repeat wait() until game.Workspace:FindFirstChild(player.Name)
local char = game.Workspace:WaitForChild(player.Name)
char:WaitForChild("Humanoid"):AddAccessory(clone)
end
end
However, when the hat is given to the player, it stays the same size as it was in the hats folder.
I’ve attempted to use X, Y, and Z values, which ended up giving me the error 'Cannot assign X to ’ and using Vector3.new(player.Size.Value.X, etc. etc.)
This is gonna sound very simple, but maybe try to resize the mesh inside the hat instead of the hat itself.
Resizing meshes only works on MeshParts, not parts with meshes in them, that’s different.
Try doing clone.Handle.Mesh.Scale = player.Size.Value
instead of clone.Handle.Size = player.Size.Value.
Edit: Also, since meshes sometimes have weird sizes/offsets, you may want to multiply the size and offset instead of manually setting them to avoid awkwardly positioned or stretched out/compressed hats.
player.Size is a Vector3 value created from the server which is updated when the character’s size is updated. Both the player.Size and the character’s size increase by increments of 0.1 on each axis. The goal is that when the accessory is given to the character, the size is updated so it matches the character’s size.
It seems to change size fine when changed in the increments, however, when the player resets and the hat is re-equipped, it remains the default size.
Do you re-reference it after re-equipping?
Could be that you’re trying to resize a hat that doesn’t exist anymore but because it’s still in memory and doesn’t get cleared the script still tries to resize it.