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

Data saving script erroring on test player 1 leaving and test player 2 joining then leaving?

Asked by 6 years ago

In this code i get the error file -2 does not exist in the module.

non module code:

01local players = game.Players
02local dataservice = game:GetService("DataStoreService")
03local playerstore = dataservice:GetDataStore("PlayerDataStore")
04local savemodule = require(game.ServerScriptService.PlayerData)
05local AUTOSAVEINT = 60
06function SaveData(player,id,cpos)
07    if(cpos == nil)then
08        cpos = Vector3.new(0,0,0)
09    end
10    local moduleindex = nil
11        for i = 1,#savemodule do
12            local playerssavestore = savemodule[i]
13        if(id == playerssavestore[1])then
14            moduleindex = playerssavestore
15        end
View all 90 lines...

module code:

01local playerinfo = {}
02 
03function playerinfo.profilecreate(playersinfo)
04    local ownprop = playersinfo
05    local newplayer = ownprop
06    table.insert(playerinfo,#playerinfo + 1,newplayer)
07end
08function playerinfo.modgold(id,amount)
09    for i = 1,#playerinfo do
10        local playersprofile = playerinfo[i]
11        if(playersprofile[1] == id)then
12            playersprofile[2] = playersprofile[2] + amount
13        end
14    end
15end
View all 24 lines...
0
I just realized it isnt proper UTF :/ 129Steve129 7 — 6y

Answer this question