"Module code does not return exactly one value" I don't know what to do

In these two scripts, I am trying to somewhat optimize my way of changing the data in the datastore when it is changed in game. I’ve come across two problems:


I’ve never had the issue where it experienced an error loading, and even though I’ve encountered the “does not return exactly one value” issue before, I still don’t know what I’ve done wrong in this place.
Here’s the module and a part of the data manager script.
DataMod:

local players = game:GetService("Players")

local dataMod = {}

function dataMod.updateData(dataType, playerData, player, referenceName)
	dataType.Changed:Connect(function()
		playerData[player.UserId].referenceName = dataType.Value
	end)
end

return dataMod

DataManager:

    local TimePlayedSeconds = playerData[player.UserId].TimePlayedSeconds
	local TimePlayedMinutes = playerData[player.UserId].TimePlayedMinutes
	local TimePlayedHours = playerData[player.UserId].TimePlayedHours
	
	timeplayed_seconds.Value = TimePlayedSeconds
	timeplayed_minutes.Value = TimePlayedMinutes
	timeplayed_hours.Value = TimePlayedHours



	dataMod.updateData(timeplayed_seconds, playerData, player, TimePlayedSeconds)
	dataMod.updateData(timeplayed_minutes, playerData, player, TimePlayedMinutes)
	dataMod.updateData(timeplayed_hours, playerData, player, TimePlayedHours)

Hopefully this all helps and you’re able to help resolve my issue! Thanks!
Edit: Also if you have any other tips to make this better in any way, send them my way too

local players = game:GetService("Players")

local dataMod = {}


function dataMod.updateData(dataType, playerData, player, referenceName)
	dataType.Changed:Connect(function()
		playerData[player.UserId].referenceName = dataType.Value
	end)
end


return dataMod.updateData

would this do any good? it seems like its returning nil given nothing is in the table, although you probably should use classes if you’re going to go this route id like to think, unsure though, sorry if this did nothing im on mobile, shoving the function inside of the table might work too, unsure though

interesting, ill try when i get home. i do know from previous experiences with modules that this probably wont work, but thanks for the pointer.

somehow the issue magically fixed itself.

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