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)

9 comments
"????" is an emoji
ur saying u are using an emoji in your script?? If that's the case you going need to remove the emoji. Emojis do not work in code.
but its a "text"so it will work right
Not quite sure, but you are using "Data" as a value for both JumpPower and Wins. Perhaps try doing something along the lines of "Data.Cash" and "Data.Kills" or have some way of connecting each value to its place
thank you
Did it work?
I didn't see yet, but I'm about to. Could you tell me exactly what to do please?
Note to my answer I just posted: It's possible the emoji can be another reason as to why it's not saving data. I suggest using letters and/or numbers without any special symbols/characters.
I removed every emoji from my scripts and its still not working like before