What's wrong with this? Have a similar one that is working in studio but not in game.
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) save = player.HatSave.Value for i,v in pairs(player:GetChildren()) do if v.ClassName == "Hat" and v.Name == save then v.Parent = player.Character end end wait(2) for i,v in pairs(character:GetChildren()) do if v.ClassName == "Hat" and v.Name ~= save then v:Destroy() end end end)
Let's start by tabbing your code correctly:
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) save = player.HatSave.Value for i, v in pairs(player:GetChildren()) do if v.ClassName == "Hat" and v.Name == save then v.Parent = player.Character end end wait(2) for i, v in pairs(character:GetChildren()) do if v.ClassName == "Hat" and v.Name ~= save then v:Destroy() end end -- If you had tabbed correctly, you would have realized you are missing an `end)` here! end)