So, I tried doing a "wins" leaderboard in Roblox. Exactly like the survivals datastore in Survive the natural disasters but with wins instead. I tried doing a "when touched, increment data" type of thing but, no luck. When a player joins, their number and name don't appear on the global leaderboard. Not even like #1: random player: 0 wins. / It just doesn't recognize the data? Also, the leaderboard is global. So like my game is that, when you arrive at the end, it adds one win. Main issue: When running the leaderboard: I get only MY data. Weird. I also added data such as a friend, he got 7 wins, but it just isn't showing on the leaderboard, help? My win script:
local deb = false
local DataStoreService = game:GetService("DataStoreService")
local experienceStore = DataStoreService:GetDataStore("PlayerWins")
function onTouched(m)
p = m.Parent:findFirstChild("Humanoid")
if p ~= nil and deb == false then
deb=true
local level = script.Parent.Parent.Parent:WaitForChild("Level"..tonumber(script.Parent.Parent.Name)+1,1)
if level then
p.Torso.CFrame = CFrame.new(script.Parent.Parent.Parent:WaitForChild("Level"..tonumber(script.Parent.Parent.Name)+1).Value)
game.Players:WaitForChild(m.Parent.Name).leaderstats.Level.Value = game.Players:WaitForChild(m.Parent.Name).leaderstats.Level.Value+1
deb=true
wait(1)
deb = false
else
pcall(function()
local player = game.Players:WaitForChild(m.Parent.Name)
local gui = script.LevelsOff:Clone()
gui.Parent = player.PlayerGui
p.Parent:WaitForChild("Torso").CFrame = CFrame.new(workspace.Levels:WaitForChild("Level1").Value)
game.Players:WaitForChild(p.Parent.Name).leaderstats:WaitForChild("Level").Value = 1
game.Players:WaitForChild(p.Parent.Name).leaderstats:WaitForChild("Wins").Value = game.Players:WaitForChild(p.Parent.Name).leaderstats:WaitForChild("Wins").Value + 1
game.ReplicatedStorage.ServerToClient:FireAllClients(player.Name,'w')
deb=false
end)
end
end
end
script.Parent.Touched:connect(onTouched)
My on join script:
local DataStoreService = game:GetService("DataStoreService")
local experienceStore = DataStoreService:GetDataStore("PlayerWins")
game.Players.PlayerAdded:Connect(function(plr)
wait(2)
local data = experienceStore:GetAsync(plr.UserId)
if data==nil then
experienceStore:SetAsync(plr.UserId,0)
end
local Com = Instance.new("IntValue")
Com.Name = "Wins"
Com.Value = 0
Com.Parent = plr.leaderstats
pcall(function()
Com.Value = data
end)
while true do
wait(15)
print("Updating datastore...")
DataStoreService:GetDataStore("PlayerWins"):SetAsync(plr.UserId,plr.leaderstats.Wins.Value)
end
end)
Help?
