I want to move a hat out of the ServerStorage and onto a character. The code is in a LocalScript inside a TextButton:
player = game.Players.LocalPlayer.Character for _, child in pairs(player:GetChildren()) do if child.ClassName == 'Hat' then child:destroy() end end local hat = game.ServerStorage.Customizer.Male.Hats.BlondeFaux:clone().Parent==player hat.Handle.CFrame = player.Head.CFrame * CFrame.new(0, player.Head.Size.Y / 2, 0) * hat.AttachmentPoint:inverse()
When I run the game, I get the following error:
00:24:04.796 - Players.Player.PlayerGui.ScreenGui.Frame.Hat.Preview:4: attempt to index local 'hat' (a boolean value)
00:24:04.798 - Stack Begin
00:24:04.799 - Script 'Players.Player.PlayerGui.ScreenGui.Frame.Hat.Preview', Line 4
00:24:04.800 - Stack End
Thanks!
Change:
local hat = game.ServerStorage.Customizer.Male.Hats.BlondeFaux:clone().Parent==player
To:
local hat = game.ServerStorage.Customizer.Male.Hats.BlondeFaux:clone() hat.Parent = player
Also, do remember that double equals is comparison; you want to set it not check if the clone's parent is equal to the player's character.