I'm making a system where when a map loads only for a specific player, it puts the map where it can be replicated to a client.
The map goes in a folder in ReplicatedStorage called "MapQueue." When a map needs to load for a certain player, it makes a folder in "MapQueue" with the player's name.
Then, it invokes a RemoteFunction to the player, where the player gets the map from the MapQueue folder and put it in the workspace. Finally, the server deletes the map from the queue.
****server script****
local replicatedStorage = game.ReplicatedStorage local queueFolder = replicatedStorage.MapQueue local playerFolder if queueFolder:FindFirstChild(player.Name) then playerFolder = queueFolder[player.Name] else playerFolder = Instance.new("Folder") playerFolder.Name = player.Name playerFolder.Parent = queueFolder end map:Clone().Parent = playerFolder replicatedStorage.LoadMap:InvokeClient(player, map.Name) queueFolder[player.Name][map.Name]:Destroy()
****client script****
local storage = game:GetService("ReplicatedStorage") local queue = storage:WaitForChild("MapQueue") local data = game:GetService("ReplicatedFirst") local player = game.Players.LocalPlayer storage:WaitForChild("LoadMap").OnClientInvoke = function(map, teleportId) if map ~= nil then local m = queue:WaitForChild(player.Name):WaitForChild(map):Clone() m.Name = "Map" m.Parent = workspace end end
I knew I was going to reuse this code in many different scripts, so I put it in a module script.
local module = {} local replicatedStorage = game.ReplicatedStorage local queueFolder = replicatedStorage.MapQueue module.LoadMapToClient = function(player, map) local playerFolder if queueFolder:FindFirstChild(player.Name) then playerFolder = queueFolder[player.Name] else playerFolder = Instance.new("Folder") playerFolder.Name = player.Name playerFolder.Parent = queueFolder end map:Clone().Parent = playerFolder replicatedStorage.LoadMap:InvokeClient(player, map.Name) queueFolder[player.Name][map.Name]:Destroy() end return module
However, when one of my scripts used the load map function from the module script, the argument "player" turned into a table and "map" turned into the player.
I checked the arguments and the parameters of the function invoke. The parameters are fine, but the arguments are unusual.
Please help me!