【发布时间】:2021-09-29 23:47:11
【问题描述】:
我正在尝试创建数据库,但仍在测试阶段,但它不起作用。
基本上错误是,我想要它,所以如果我输入:ModuleScript:GetDB("salvage").Set("key", "value"),它会返回一个值,但不是因为错误。
非常感谢任何帮助。
错误: Photo
服务器脚本:
local ModuleScript = require(game.ServerStorage.ModuleScript)
game.Players.PlayerAdded:Connect(function(p)
p.Chatted:Connect(function(msg)
if msg == "t" then
print("lol")
print(ModuleScript:GetDB("salvage"))
ModuleScript:GetDB("salvage").Set("key", "value")
end
end)
end)
模块脚本:
--Variables
local dss = game:GetService("DataStoreService")
-- Tables
local greenwich = {}
local dbFunctions = {}
--Functions
function greenwich:GetDB(name)
local db = dss:GetDataStore(name)
local new = {}
new.store = db
coroutine.resume(coroutine.create(function()
for k, v in ipairs(dbFunctions) do
new[k] = function(...)
local args = { ... }
v(new.store, unpack(args))
end
end
end))
print(new.store.Name, name)
return new
end
function dbFunctions:Set(store, key, value)
print(value)
return value
end
--Returning everything.
return greenwich
提前致谢。
【问题讨论】: