diff --git a/Individual Components/SystemTemplate.rbxm b/Individual Components/SystemTemplate.rbxm index 48e82c0..ba2fcef 100644 Binary files a/Individual Components/SystemTemplate.rbxm and b/Individual Components/SystemTemplate.rbxm differ diff --git a/README.md b/README.md index b8bc505..cd73274 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,9 @@ ## TODO - [ ] Make installation instructions - [ ] Alarm reporting Roblox-Side script -- [ ] More detailed Readme \ No newline at end of file +- [ ] More detailed Readme +- [X] Use datastores for code storage + +## Having multiple separate systems +To put it simply, you just need to set the `dataStoreKey` string to *anything you want* +If you want systems to share codes, use the same dataStoreKey (This is not supported, and may cause issues.) \ No newline at end of file diff --git a/Scripts/SecuritySystem.lua b/Scripts/SecuritySystem.lua index af2d0e1..0f1f8cf 100644 --- a/Scripts/SecuritySystem.lua +++ b/Scripts/SecuritySystem.lua @@ -1,9 +1,16 @@ +local DataStoreService = game:GetService("DataStoreService") +local dataStore = DataStoreService:GetDataStore('securityCodes-' .. script.Parent.dataStoreKey.Value or "XP-99") + function setup(parentScript) -- dont touch - version = "v1.0.1" + version = "v1.2.0" -- codes object, will be swapped for data store later - codes = {"1234"} + codes = dataStore:GetAsync("codes") + if not codes then + codes = {"1234"} + dataStore:SetAsync("codes", codes) + end -- Make a settings object mapped to the values in parentScript.Parent.Settings settings = {} @@ -343,6 +350,7 @@ delay return else codes[tonumber(uid)] = nil + dataStore:SetAsync("codes", codes) ding(1) end deauth() @@ -354,6 +362,7 @@ delay if newCode == newCodeVerify then if not table.find(codes, newCode) then codes[tonumber(uid)] = newCode + dataStore:SetAsync("codes", codes) ding(1) else ding(4) @@ -548,7 +557,7 @@ delay task.spawn(stateLoop) end - + function stateLoop() while true do script.Parent.armState.Value = armState