setmetatable overwrites the existing metatable of data, which is currently a reference to the profile, so it no longer has access to methods in class Profile in ProfileService.
As I understand your aim is to expand data with additional properties and methods. Aside from metatable complications, that exposes some risks in the long run, especially the chance to accidentally overwrite elements that belong to the profile.
I suggest your create a wrapper and treat the profile as a member of the object rather than the object itself.
For instance:
function module.new(player, profile)
local object = setmetatable({}, module)
object.Profile = profile
object.Player = player
-- ...
return object
end
-- And then have methods like:
function module:HasUgc(id)
return if table.find(self.Profile.Data.GottenUgc, id) then true else false
end
Both scripts also need a review, especially a couple of things, such as:
players[plr.Name] and players[plr], which are not the same;
as well as clear distinction between self.Data.leaderstats (which would be safer as self.Profile.Data.leaderstats) and the leaderstats folder self.Data.plr.leaderstats (which should not be a part of Profile.Data and rather a separate field in the object).