I have 2 scripts that could be causing this (Code will be at the end.) The first script is the one that creates the leaderboard. The second script is the one that saves the players' data. It is most likely the PlayerEntered or PlayerAdded functions causing this. (I am bad at both.) Any help would be appreciated, thanks!
Roblox account: Happyhal75
First script (Leaderboard)
game.Players.PlayerAdded:connect(function(p)
local stats = Instance.new("IntValue")
stats.Name = "leaderstats"
stats.Parent = p
local money = Instance.new("IntValue")
money.Name = "Obby Wins" -- Change "Money" to anything you want to name it like "Cash"
money.Parent = stats
end)
Second script: (Saver)
local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("GemSaveSystem")
game.Players.PlayerAdded:connect(function(plr)
local folder = Instance.new("Folder", plr)
folder.Name = "leaderstats"
local gems = Instance.new("IntValue", folder)
gems.Name = "Obby Wins"
gems.Value = ds1:GetAsync(plr.UserId) or 0
ds1:SetAsync(plr.UserId, gems.Value)
gems.Changed:connect(function()
ds1:SetAsync(plr.UserId, gems.Value)
end)
end)

3 comments
Do you use Free Models (models got from Toolbox)? May be there is an malicious code at one of it.
You should not seperate the DataStore scripts. Keep the saver and leaderstats maker together.
Ok! Will try that! :)