I was following a Tutorial on how to use ProfileService DataStore made by @okeanskiy
Video Title on YT: Intro to ProfileService DataStore Module: Basic Usage (Roblox Studio)
Error I got from output is Module code did not return exactly one value
and Requested module experienced an error while loading
I don’t have any solution for this because I don’t know the problem. Maybe, I’m just blind and did not see any typing error or missed some codes from the tutorial.
DataManager (modulescript)
local Players = game:GetService("Players")
local ProfileService = require(game.ReplicatedStorage.ProfileService)
local ProfileStore = ProfileService.GetProfileStore(
"Player",
{
money = 0;
lastUserdMoneyPartTime = 0;
}
)
local Profiles = {}
local function onPlayerAdded(player)
local profile = ProfileStore:LoadProfileAsync(
"Player_".. player.UserId,
"ForceLoad"
)
if profile then
profile:ListenToRelease(function()
Profiles[player] = nil
player:Kick()
end)
if player:IsDescendantOf(Players) then
Profiles[player] = profile
else
profile:Release()
end
else
player:Kick()
end
end
local function onPlayerRemoving(player)
local profile = Profiles[player]
if profile then
profile:Release()
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
Players.PlayerRemoving:Connect(onPlayerRemoving)
local DataManager = {}
function DataManager:Get(player)
local profile = Profiles[player]
if profile then
return profile.Data
end
end
Just in case, I put this money script too if the error caused from here
Money (script)
local DataManager = require(game.ReplicatedStorage.DataManager)
local part = workspace.Money
local function onTouched(touchedPart)
local player = game.Players:GetPlayerFromCharacter(touchedPart.Parent)
if player then
local data = DataManager:Get(player)
if data then
local currentTime = os.time()
local timeSinceLastUsedMoneyPart = currentTime - data.lastUsedMoneyPartTime
local waitTime = 10*60
if timeSinceLastUsedMoneyPart > waitTime then
data.lastUsedMoneyParTime = currentTime
data.money += 500
print(player.Name, "now has money:", data.money)
else
print(player.Name, "must wait seconds before use: ", waitTime - timeSinceLastUsedMoneyPart)
end
else
print(player.Name, "does not have data profile loaded")
end
end
end
part.Touched:Connect(onTouched)
Thank you in advanced