I am doing things a bit differently to prevent hacking, even though I have filtering enabled, make sure you read otherwise you are going to give me the wrong answer.
Rather than using leaderboardstats as the location to store data, I am simply using it as a means of displaying the values. The REAL values are located in ServerStorage. Here is my script that creates the data for players in both ServerStorage and then an empty leaderboard stat.
game.Players.PlayerAdded:connect(function(player)
local entry = player.Name
local model = Instance.new("Model", game.ServerStorage)
local timeplayed = Instance.new("IntValue", game.ServerStorage.Model)
timeplayed.Name = "Minutes"
model.Name = entry
local stats = Instance.new("IntValue")
stats.Parent = player
stats.Name = "leaderstats"
local timeplayed2 = Instance.new("IntValue")
timeplayed2.Parent = player.leaderstats
timeplayed2.Name = "Minutes"
end)
Remember, everything in leaderstats is just mean to be like a GUI, its just meant to display the data, not actually be the important place that stores it.
Now, I have a separate script that is supposed to add 1 to the IntValue located in ServerStorage and then afterwards set the value of the IntValue in the leaderstats to the IntValue in ServerStorage
game.Players.PlayerAdded:connect(function(player)
local entry = player.Name
local data = game.ServerStorage:FindFirstChild(player.Name)
assert(data, "PlayerData not created yet for `" .. player.Name .. "`")
local minutesServerStorage = data.Minutes
local minutesLeaderboards = player:WaitForChild("leaderstats").Minutes
while true do wait()
minutesServerStorage.Value = minutesServerStorage.Value + 1
wait(1)
minutesLeaderboards.Value = game.ServerStorage[entry].Minutes.Value --Sync the Coins IntValue in ServerStorage with one in leaderstats
wait(1)
end
end)
When I test my game, I have both a serverstorage and leaderstats of the data, the problem seems to lie with the while true do not updating the IntValue in serverstorage and in leaderboards.
