Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is my datastore script not working on line 9?

On line 9 the (Table[Plr]) part has an error.

SCRIPT:

local DataStore = game:GetService('DataStoreService'):GetDataStore('Data')
local Table = {"Cash"}

game:GetService('Players').PlayerAdded:Connect(function(Plr)
	local DKey = 'Key'.. Plr.UserId
	local Data = DataStore:GetAsync(DKey) or {
	Cash = 0
	},
	Table[Plr]
end)


game:GetService('Players').PlayerRemoving:Connect(function(Plr)
	local DKey = 'Key'.. Plr.UserId
	local Data = Table[Plr]
	DataStore:SetAsync(DKey, Data)
end)

2 comments

0

What kind of error in the console?

0

Statement spans multiple lines; Use indentation to silence.

1 answer

✓ Accepted answer

you script has too much information, the computer cannot think so much.

from line 06,

local Data = DataStore:GetAsync(DKey)
if not Data then
	Data = {Cash = 0}
end
Table[Plr] = Data

This discussion is preserved as it was. New answers, comments, and votes are closed.