I've been making a game where you have to click a button to gain jump power, but later I realized that the stats won't save and people can't see others score on the board, they only see their score. This is my local script for the button and my leaderboard. Tell me if you need to see other scripts or anything.
local script:
local player = game.Players.LocalPlayer local jumpPower = player:WaitForChild("leaderstats"):WaitForChild("Jump Power") local RS = game.ReplicatedStorage local ClickedEvent = RS.Clicked local debounce = false function onClicked() if debounce == false then debounce = true jumpPower.Value = jumpPower.Value + 0.1 if player:WaitForChild("PremiumDouble").Value == true then jumpPower.Value = jumpPower.Value + 0.1 end ClickedEvent:FireServer() script.Parent.Sound:Play() wait(0.2) debounce = false end end script.Parent.MouseButton1Click:Connect(onClicked)
leaderboard:
local DataStoreService = game:GetService("DataStoreService") local DataStore = DataStoreService:GetDataStore("SkinStats") -- maybe this needs to be changed lmk game.Players.PlayerAdded:Connect(function(Player) local Leaderstats = Instance.new("Folder") Leaderstats.Name = "leaderstats" Leaderstats.Parent = Player local JumpPower = Instance.new("NumberValue") JumpPower.Name = "Jump Power" JumpPower.Value = 0 JumpPower.Parent = Leaderstats local Wins = Instance.new("IntValue") Wins.Name = "Wins ????" Wins.Value = 0 Wins.Parent = Leaderstats local PremiumDouble = Instance.new("BoolValue") PremiumDouble.Name = "PremiumDouble" PremiumDouble.Parent = Player local Data = DataStore:GetAsync(Player.UserId) if Data then JumpPower.Value = Data Wins.Value = Data end end) game.Players.PlayerRemoving:Connect(function(Player) DataStore:SetAsync(Player.UserId, { ["Cash"] = Player.leaderstats["Jump Power"].Value; ["Kills"] = Player.leaderstats["Wins ????"].Value; }) end)
I see you are using this code to get the player's data.
if Data then JumpPower.Value = Data Wins.Value = Data end
I believe your issue can be because of not loading the data correctly. Both values are addressed as "Data", but how would the game know which one is which?
You use the code below to address the saved data.
["Cash"] = Player.leaderstats["Jump Power"].Value; ["Kills"] = Player.leaderstats["Wins ????"].Value;
So, what I suggest trying is:
if Data then JumpPower.Value = Data["Cash"] --or Data.Cash Wins.Value = Data["Kills"] --or Data.Kills (I don't have Studio opened right now and can't exactly tell) end
By the way, I highly suggest using a plugin to view the datastore's saved data. The one I'm using is https://www.roblox.com/library/701506235/DataStore-Editor but it's paid.
You can't use emojis in code is most likely the issue in your script
Hope this helps!!