The points are added with server scripts
Here it’s working, I didn’t change anything in the script…
Is the script located in ServerScriptService?
That’s very odd then. I’ve tried multiple times in my studio and it hasn’t worked
yes its located in server script service
Try launching the game again, and then waiting at least 10 seconds before stopping.
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local WinsData = DataStoreService:GetDataStore("WinsData")
local function leaderboardSetup(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Wins = Instance.new("IntValue")
Wins.Name = "Wins"
Wins.Value = 0
Wins.Parent = leaderstats
local Coins = Instance.new("IntValue")
Coins.Name = "Coins"
Coins.Value = 0
Coins.Parent = leaderstats
local data, data2
local success, errormessage = pcall(function()
data = WinsData:GetAsync(player.UserId.."-wins")
data2 = WinsData:GetAsync(player.UserId.."-coins")
end)
if success then
print("Data Loaded!")
Wins.Value = data
Coins.Value = data2
else
print("Couldn't load Data!")
warn(errormessage)
end
end
-- Connect the "leaderboardSetup()" function to the "PlayerAdded" event
Players.PlayerAdded:Connect(leaderboardSetup)
Players.PlayerRemoving:Connect(function(player)
print("Data Saving...")
local success, errormessage = pcall(function()
print("Starting Save")
local winsSaved = WinsData:SetAsync(player.UserId.."-wins", player.leaderstats.Wins.Value)
if not winsSaved then
error("Failed to save wins for player "..player.Name)
else
print("wins saved")
end
local coinsSaved = WinsData:SetAsync(player.UserId.."-coins", player.leaderstats.Coins.Value)
if not coinsSaved then
error("Failed to save coins for player "..player.Name)
else
print("coins saved")
end
end)
if success then
print("Player Data Successfully Saved!")
else
print("Couldn't Save!")
warn(errormessage)
end
end)
Remove game:BindToClose(wait), that’s probably what is giving you an error
Removing BindToClose doesn’t help either
I don’t see how that would be giving him an error although still go through with it because it doesn’t seem to be helping
Idk if my studio is bugged or what, but it refuses to work
Don’t change it for the client…
The Server does not Recognize Client Changes, Client Changes only affect the Player, you have to change it via Current Server, Command Line, or Developer Console.
It’s working perfectly, when you add points, you have to use the server side:
Since the script is server-side, if you change it locally it won’t work, because the information you changed is only sent to the client, so the server doesn’t receive that information.
An example when testing click here and switch to client:
For the server to receive information from the client, use remote event.
No, that would make your system vulnerable to Exploits.
Yes, but it is just an example.
Still, It isnt a good idea to suggest the usage of it in this manner, The Client can be very Inaccurate with its information.