Is there a problem with my script, also leader board doesn't show up and save data. I'll just give the whole script
local dataStores = game:GetService("DataStoreService"):GetDataStore("CashDataStore") local defaultCash = 0 local playersLeft = 0 game.Players.PlayerAdded:Connect(function(player)
playersleft = playersLeft + 1
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local cash = Instance.new("IntValue")
cash.Name = "Cash"
cash.Value = 0
cash.Parent = leaderstats
player.CharacterAdded:Connect(function(character)
character.Humanoid.WalkSpeed = 16
character.Humanoid.Died:Connect(function()
--Whenever someone dies, this event will run
if character.Humanoid and character.Humanoid:FindFirstChild("creator") then
game.ReplicatedStorage.Status.Value = tostring(character.Humanoid.creator.Value).."KILLED"..player.name
end
if character:FindFirstChild("GameTag") then
character.Gametag:Destroy()
end
player.LoadCharacter()
end)
end)
-- Data Stores
local player_data
pcall(function()
player_data = dataStores:GetAsync(player:UserId"-Cash") --872526582-Cash
end)
if player_data ~= nil then
-- Player has saved data , load it in
else
-- New player
cash.Value = defaultCash
end
end)
local bindableEvent = Instance.new("BindableEvent")
game.Players.PlayerRemoving:Connect(function(player)
pcall(function()
dataStores:SetAsync(player.UserId.."-Cash",player.leaderstats.Cash.Value)
print("Saved")
playersLeft = playersLeft - 1
bindableEvent:Fire()
end)
end)
game:BindToClose(function() -- This wil be triggered upon shutdown while playersLeft > 0 do end end

1 comment
Leadderboard doesn't show up