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.
Why is your script in server storage sir? Put it in ServerScriptService sir