Inheritance problem with RemoteFunction

So problem is when Player1 tries to place, it’s only taking into account Player2s stuff so, big problem is, every new player that joins, will be working fine, but all the older players wont have it working. So how can I get the remote function to work with this inheritance stuff correctly?

I need to use RemoteFunction too, as I return stuff from it, a lot easier than having to do client-server-client with a RemoteEvent

-- when player joins, fire this
function PlotManager:new(player)
    self.Owner = player
    self.PlayerData = PlayerData[self.Owner.UserId]
    self.Coords = {}
    
    self.PlotLoaded = false
    print("New plot for", player.Name)
    -- Get all modules
    for _, v in pairs(script:GetChildren()) do
        local Module = require(v)(self)
        
        self.Maid:GiveTask(Module)
    end
end

-- this is a module under PlotManager
function PlaceBlock:new(handler)
    self.Handler = handler
    print("New PlaceBlock module for", self.Handler.Owner)
    Functions.PlaceBlock.OnServerInvoke = function(player, block, cFrame, slab, textureInfo)
                print(player, self.Handler.Player)
        end)
end
2 Likes

I mean can’t you just loop through all the existing players before connecting to the PlayerAdded event? Like this:

for _,player in pairs(game.Players:GetPlayers()) do
    PlotManager:new(player)
end
game.Players.PlayerAdded:Connect(function(player)
    PlotManager:new(player)
end)

You do an OnServerInvoke inside a function. Every time that function runs its going to reconnect that event, which you don’t want. Move the OnServerInvoke function outside of any functions.

1 Like

There’s an additional unnecessary closing bracket at the end of the second to last end statement.

I’ll take a look at the other mentioned issues in a moment.