I want to make a module script for my inventory, but i have no idea how do i change what is it going to return. Here is the complete script:
local dss=game:GetService('DataStoreService'):GetDataStore('GameStuff')
function changeTable(t,change)
local invthings={'Knifes','ChosenKnife','Citrines','Coins'}
for i=1,#change do
t[invthings[i]]=change[invthings[i]]
end
end
game.Players.PlayerAdded:connect(function(player)
print'player joined'
if string.sub(player.Name,1,6)=='Guest ' then
player:Kick('Sorry,but this game does not support guests due to the data store feature. Please log in or create an account to play this game')
else
local key='id='..player.userId
local async=dss:GetAsync(key)
print'async obtained'
if not async then
dss:SetAsync(key,{Knifes={1},ChosenKnife=1,Citrines=0,Coins=0})
async=dss:GetAsync(key)
print'created new async'
end
local inventory=script.Inventory:Clone()
print'inventory module cloned'
inventory.Parent=player
print'inventory module parented to player'
changeTable(inventory,async)
end
end)
game.Players.PlayerRemoving:connect(function(player)
local key='id='..player.userId
local inventory=player.Inventory
dss:SetAsync(key,require(inventory))
end)
