When I try to change player data using a module script, it gives me an error... Any help would be nice.
Error: 23:09:45.463 - ReplicatedStorage.ModuleScript:14: attempt to concatenate field 'UserId' (a nil value)
ModuleScript:
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
Script:
script.Parent.MouseClick:Connect(function(plr)
print(plr)
local module = require(game.ReplicatedStorage.ModuleScript)
module.ChangeStat(plr, "Money", 100)
end)
P.S: I'm really new to using module scripts...

2 comments
short answer, change the period on line 4 of your script to a colon
Thanks. Now im getting a new error. On like 3 of module script.