---Important Things---
So I have a LeaderBoard and a Data Store that seems to not work with the LeaderBoard, but why? What went wrong in the scripts?
---Locations--- -TheData Store Script is in the ServerScriptService. -The Leaderboard is in the ServerScriptService.
---LeaderBoard (Working)---
game.Players.PlayerAdded:connect(function(p) local stats = Instance.new("IntValue", p) stats.Name = "leaderstats" local cash = Instance.new("IntValue", stats) cash.Name = "Cash" cash.Value = 0 while true do wait(30) cash.Value = cash.Value + 50 end end)
---Data Store(Not Working)---
local DSService = game:GetService("DataStoreService"):GetDataStore("vincentthecat1") game.Players.PlayerAdded:Connect(function(Plr) local uniquekey = 'id-'..Plr.userid local LeaderBoard = Instance.new('IntValue',Plr) local savevalue = Instance.new('IntValue') LeaderBoard.Name = 'LeaderBoard' savevalue.Parent = LeaderBoard savevalue.Name = 'Cash' end)
I don't see any way you are saving data
if you wanted to save a data you either do :SetAsync or :UpdateAsync
for example
local DataStoreService = game:GetService("DataStoreService") game.Players.PlayerAdded:Connect(function(Player) local Intvalue = Instance.new("IntValue") Intvalue.Value = DataStoreService:GetAsync(Player.UserId) --To Get Whatever data you saved Intvalue.Parent = workspace Intvalue.Name = Player.UserId end) game.Players.PlayerRemoving:Connect(function(Player) local ValueToSave = game.Workspace[Player.UserId] ValueToSave:SetAsync(DataStoreService,Player.UserId) end)