Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Module Script Output Error For Data Storage ?

Asked by
Zeklou 0
6 years ago
Edited by M39a9am3R 6 years ago

I am experiencing this error in the output and it leads to my module script

"Requested module experienced an error while loading"

Iv'e done some searching around and people say that the Module return must be missing but it isn't. This module script is meant for data storage, here it is.

local module = {}

local DataStore = game:GetService("DataStoreService"):GetDataStore("Test184748947")

local StartingNewbucks = 100

game.Players.PlayerAdded:connect(function(player)

local Stats = Instance.new("Folder", player)
Stats.Name = "Newbucks"

local Newbucks = Instance.new("NumberValue",Stats)
Newbucks.Name = "Newbucks"
Newbucks.Value = StartingNewbucks

local SavedNewbucks = DataStore:GetAsync(player.userId .. "-Newbucks")
if SavedNewbucks ~= nil then
    Newbucks.Value = SavedNewbucks
end

game.Players.PlayerRemoving:connect(function(player)
    local id = player.userId

    local NewbucksValue = player.Newbucks.Newbucks.Value DataStore:SetAsync(id.."-Newbucks", NewbucksValue)
    DataStore:Setasync(id.."-Newbucks",NewbucksValue)
end)

end)


return module

Answer this question