You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to make a game. -
What is the issue? Include screenshots / videos if possible!
data doesn’t save??? it loads but doesn’t save, no error or something. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i tried many solutions but none of them worked.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local checkpoints = workspace.Spawn
local Datastore = game:GetService("DataStoreService")
local lData = Datastore:GetDataStore("LeaderboardData")
game.Players.PlayerAdded:Connect(function(p)
local AC = Instance.new("Folder",p)
AC.Name = "AntiCheat"
local B = Instance.new("BoolValue", AC)
B.Name = "Banned"
local W = Instance.new("IntValue", AC)
W.Name = "Warnings"
W.Value = 0
local l = Instance.new("Folder", p)
l.Name = "leaderstats"
local stage = Instance.new("IntValue", l)
stage.Name = "Stages"
stage.Value = 0
local r = Instance.new("NumberValue", l)
r.Name = "Rebirths"
r.Value = 0
local c = Instance.new("NumberValue", l)
c.Name = "Coins"
c.Value = 0
local s = Instance.new("Folder", p)
s.Name = "SkipFolder"
local AS = Instance.new("IntValue",s)
AS.Name = "AmountSkip"
AS.Value = 15
local MaS = Instance.new("IntValue",s)
MaS.Name = "MaxSkip"
MaS.Value = 15
local MiS = Instance.new("IntValue",s)
MiS.Name = "MinSkip"
MiS.Value = 0
local cData
local sData
local rData
local skData
local work,nvm = pcall(function()
cData = lData:GetAsync("Coins-"..p.UserId)
sData = lData:GetAsync("Stages-"..p.UserId)
rData = lData:GetAsync("rebirth-"..p.UserId)
skData = lData:GetAsync("Skips-"..p.UserId)
end)
wait(2.5)
if work then
c.Value = cData
r.Value = rData
stage.Value = sData
AS.Value = skData
print("Data Succesfully Loaded")
end
p.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
wait()
character:MoveTo(checkpoints[stage.Value].Position)
humanoid.Touched:Connect(function(hit)
if hit.Parent == checkpoints then
if tonumber(hit.Name) == stage.Value + 1 then
stage.Value = stage.Value + 1
end
end
end)
end)
while wait() do
if stage.Value > 100 then
stage.Value = 100
end
end
end)
game.Players.PlayerRemoving:Connect(function(p)
print("a1")
local work,nvm = pcall(function()
print("a2")
lData:SetAsync("Coins-"..p.UserId, p.leaderstats.Coins.Value)
print("a3")
lData:SetAsync("Stages-"..p.UserId, p.leaderstats.Stages.Value)
print("a4")
lData:SetAsync("rebirth-"..p.UserId, p.leaderstats.Rebirths.Value)
print("a5")
lData:SetAsync("Skips-"..p.UserId, p.SkipFolder.AmountSkip.Value)
print("a6")
end)
print("a2")
if work then
print("a3")
print("Data Successfully Saved")
print("a4")
elseif nvm then
print("a5")
print("Failed: ", nvm)
print("a6")
end
print("a10")
end)
the a1, a2 or something is for debugging.
it only prints a1, a2 for the first one and the rest doesn’t print.
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.