In my last question, I was asking how to use AddAccessory properly (I don't use it now). Now I've gotten my answer and it works perfectly in Studio, no bugs! However, when I launch a test server and then test it out, I click on the button that the hat comes from and absolutely nothing happens. This has happened before, and it was because I was not Finding First Child or I didn't wait for everything to be identified. Can someone help me quickly identify the thing I need to fix here so it will work in-game? The code is shown below:
function click() local accessory = game.Lighting.meshes.example:Clone() local player = game.Players.LocalPlayer local playercharacter = game.Players.LocalPlayer.Character local playername = player.Name local humanoid = game.Workspace:FindFirstChild(playername) --Hat Equips Here accessory.Parent = playercharacter end script.Parent.MouseButton1Click:connect(click)