script.Parent.PlayerAdded:connect(function(player) k = game.Players.LocalPlayer k.Character:IsA("Hat") k.MeshId = "http://www.roblox.com/asset/?id=20011951" end)
You're using the IsA function. This function only returns a true or false value.
If you wanted this to work you would have to do this:
script.Parent.PlayerAdded:connect(function(player) for i,obj in pairs (game.Players.LocalPlayer.Character:GetChildren()) do if obj.ClassName == "Hat" then obj.Handle.Mesh.MeshId == "http://www.roblox.com/asset/?id=20011951" end end end)
Make sure this runs in a local script.