Module script changes arguments

I have this issue in my ModuleScript where it changes the 2 arguments that I send in.
Module

local ToolHandler = {}
ToolHandler.localPlayer = game.Players.LocalPlayer

function ToolHandler.CreateTool(player, playerTool)
	local newTool = {}
	setmetatable(newTool, ToolHandler)
	print(playerTool) -- Prints my player
	print(player) -- Prints (screenshot)
	local tool = character:FindFirstChild(playerTool.Name)

	return newTool
end

return ToolHandler

Remote

ReplicatedStorage = game:GetService("ReplicatedStorage")

local CreateToolEvent = ReplicatedStorage.Remotes.Functions.CreateTool
local ToolHandler = require(ReplicatedStorage.Assets.Handlers.ToolHandler)

CreateToolEvent.OnServerInvoke = function(player)
	local tool = character:FindFirstChildOfClass("Tool")
	if not tool then return end
	
	local newTool = ToolHandler:CreateTool(player, tool)

end

The print(playerTool) prints my player name “TheParkourGamer10”

The print(player) prints this

image

If you check you can see that the arguments that I send in are my player (#1) and my tool (#2)
The arguments that the module prints are the module table (#1) itself and then my player (#2)

1 Like

Figured out the first argument is the metatable, didnt know that sorry…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.