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

Im trying to get my data store script in server script service to work but its not??

Im trying to get my data store script to work but there where 0 errors and it did not work any idea why? It also keeps all stats at 0.

local datastore = game:service("DataStoreService"):GetDataStore("OG-OMDA")

game.Players.PlayerAdded:connect(function(p)
local ls = Instance.new("IntValue", p)
ls.Name = "leaderstats"

local Coins = Instance.new("IntValue", ls)
Coins.Name = "Coins"

local Lvl = Instance.new("IntValue", ls)
Lvl.Name = "Lvl"

local XP = Instance.new("IntValue", ls)
XP.Name = "XP"

local Diamonds = Instance.new("IntValue",ls)
Diamonds.Name = "Diamonds"

			XP.Changed:connect(function()
		Lvl.Value = math.floor(XP.Value / 500)

local k = datastore:GetAsync(p.Name.."key")
if k then
Coins.Value = k[1]
Lvl.Value = k[2]
XP.Value = k[3]
Diamonds.Value = k[4]
else
datastore:SetAsync(p.Name.."key", {Coins.Value,Lvl.Value,XP.Value,Diamonds.Value})
end
end)

game.Players.PlayerRemoving:connect(function(p)
local st = {p.leaderstats.Coins.Value,p.leaderstats.Lvl.Value,p.leaderstats.XP.Value,p.leaderstats.Diamonds.Value}
datastore:SetAsync(p.Name.."key",st)
end)
end)

Please help.

1 answer

✓ Accepted answer

Why is your script in server storage sir? Put it in ServerScriptService sir

3 comments

0

it is in serverscriptservice

0

sorry typo

0

o

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