I have this in a modulescript in serverscriptservice:

local PlayerStatManager = {}

-- This code is pretty unrelated, scroll down to "callvalue"

local DataStoreService = game:GetService("DataStoreService")
local playerData = DataStoreService:GetDataStore("PlayerData")
local sessionData = {}

function PlayerStatManager:ChangeStat(player, statName, value)
	local playerUserId = "Player_" .. player.UserId
	assert(typeof(sessionData[playerUserId][statName]) == typeof(value), "ChangeStat error: types do not match")
	if typeof(sessionData[playerUserId][statName]) == "number" then
		sessionData[playerUserId][statName] = sessionData[playerUserId][statName] + value
	else
		sessionData[playerUserId][statName] = value
	end
end
 
local function setupPlayerData(player)
	local playerUserId = "Player_" .. player.UserId
	local data = playerData:GetAsync(playerUserId)
	if data then
		-- Data exists for this player
		sessionData[playerUserId] = data
	else
	local playerUserId = "Player_" .. player.UserId
	sessionData[playerUserId] = {Skips=3}
	end
end

-- The rest is pretty irrelevant, callvalue has an issue

function PlayerStatManager:callvalue(player, statName)
	print(player)
	local playerUserId = "Player_" .. player.UserId
	if typeof(sessionData[playerUserId][statName]) == "number" then
		return sessionData[playerUserId][statName]
	end
	end

game.Players.PlayerAdded:Connect(setupPlayerData)

return PlayerStatManager

Whenever I use call the function "callvalue, it prints out the statName I defined as "Skips" instead of the player name The problematic Line is line 35 here

A script in the workplace, That is calling for the modulescript function:


local call = require(game.ServerScriptService.scriptservice)



function printe(player)
	wait(0.5)
	local a = call.callvalue(player, "Skips")
	print(a)
end


game.Players.PlayerAdded:Connect(printe)

The error occurs and instead of Printing the "player" it prints out the statName which is called "Skips" Why? Functions have been particularly hard to understand for me. So any help would be greatly appreciated.