Hello, I made a leaderboard that saves and load the values. An normal obby checkpoint system i added too works fine that part. In this leaderboard is an level up system* Here code:
game.Players.PlayerAdded:connect(function(player) TWEE.Changed:connect(function(New) local function DRIE() local needed = (DRIE.Value*120) if TWEE.Value >= needed then DRIE.Value = DRIE.Value +1 TWEE.Value = TWEE.Value-needed DRIE() end end end) end)
Its may a bit confusing of the DB... aa and stuff .
But i thinks the script isnot working bc i added to much game.Players.PlayerAdded:connect(function(player)
in one >function may its the problem, but if i take the save and load out of the function it doesnt find if Da then EEN.Value = Da end
(Line 83 until 91)
But if some know how to fix it, i will be very happy. so i can keep working on my game.
Full leaderboard;
local Datastore = game:GetService("DataStoreService"):GetDataStore("DataA") function VAR(object) local player = game.Players:playerFromCharacter(object) if player ~= nil then local AA = player.leaderstats local AB = game.Workspace:FindFirstChild(AA.LVL.Value) print("Checking..") object.Torso.CFrame = object.Torso.CFrame + Vector3.new(0,3,0) wait() object.Torso.CFrame = AB.CFrame + Vector3.new(0,3,0) end end -- "AB = Checkpoint" "XOP = Experience" "QW = Wins" "LP = Loses" "IPE = Coins" "TR = Trofee" "DHJK = Money" "FERT = Level" "KLOPT = Gemspoins" function KOE(object) if object.className == "Player" then local stats = Instance.new('IntValue') stats.Name = "leaderstats" local EEN = Instance.new('IntValue') EEN.Name = "LVL" -- Checkpoint (Da) EEN.Value = 1 EEN.Parent = stats stats.Parent = object local TWEE = Instance.new('IntValue') TWEE.Parent = stats TWEE.Name = "XOP" -- XP (Db) TWEE.Value = 0 local DRIE = Instance.new('IntValue') DRIE.Parent = stats DRIE.Name = "FERT" -- Level (Dc) DRIE.Value = 0 local VIER = Instance.new('IntValue') VIER.Parent = stats VIER.Name = "QW" -- Wins (Dd) VIER.Value = 0 local VIJF = Instance.new('IntValue') VIJF.Parent = stats VIJF.Name = "LP" -- Loses (De) VIJF.Value = 0 local ZES = Instance.new('IntValue') ZES.Parent = stats ZES.Name = "DHJK" -- Money (Df) ZES.Value = 0 local ZEVEN = Instance.new('IntValue') ZEVEN.Parent = stats ZEVEN.Name = "IPE" -- Coins (Dg) ZEVEN.Value = 0 local ACHT = Instance.new('IntValue') ACHT.Parent = stats ACHT.Name = "TR" -- Trofee (Dh) ACHT.Value = 0 local NEGEN = Instance.new('IntValue') NEGEN.Parent = stats NEGEN.Name = "KLOPT" -- Gems (Di) NEGEN.Value = 0 game.Players.PlayerAdded:connect(function(player) TWEE.Changed:connect(function() local function DRIE() local needed = (DRIE.Value*120) if TWEE.Value >= needed then DRIE.Value = DRIE.Value +1 TWEE.Value = TWEE.Value-needed DRIE() end end end) end) game.Players.PlayerAdded:connect(function(player) local Da = Datastore:GetAsync(tostring(player.userId)..":DA") local Db = Datastore:GetAsync(tostring(player.userId)..":DB") local Dc = Datastore:GetAsync(tostring(player.userId)..":DC") local Dd = Datastore:GetAsync(tostring(player.userId)..":DD") local De = Datastore:GetAsync(tostring(player.userId)..":DE") local Df = Datastore:GetAsync(tostring(player.userId)..":DF") local Dg = Datastore:GetAsync(tostring(player.userId)..":DG") local Dh = Datastore:GetAsync(tostring(player.userId)..":DH") local Di = Datastore:GetAsync(tostring(player.userId)..":DI") if Da then EEN.Value = Da end if Db then TWEE.Value = Db end if Dc then DRIE.Value = Dc end if Dd then VIER.Value = Dd end if De then VIJF.Value = De end if Df then ZES.Value = Df end if Dg then ZEVEN.Value = Dg end if Dh then ACHT.Value = Dh end if Di then NEGEN.Value = Di end end) game.Players.PlayerRemoving:connect(function(player) local Stats = player:FindFirstChild("leaderstats") if Stats then local DAA = Stats:FindFirstChild("LVL") local DBB = Stats:FindFirstChild("XOP") local DCC = Stats:FindFirstChild("FERT") local DDD = Stats:FindFirstChild("QW") local DEE = Stats:FindFirstChild("LP") local DFF = Stats:FindFirstChild("DHJK") local DGG = Stats:FindFirstChild("IPE") local DHH = Stats:FindFirstChild("TR") local DII = Stats:FindFirstChild("KLOPT") if DAA then Datastore:SetAsync(tostring(player.userId)..":DA", EEN.Value) end if DBB then Datastore:SetAsync(tostring(player.userId)..":DB", TWEE.Value) end if DCC then Datastore:SetAsync(tostring(player.userId)..":DC", DRIE.Value) end if DDD then Datastore:SetAsync(tostring(player.userId)..":DD", VIER.Value) end if DEE then Datastore:SetAsync(tostring(player.userId)..":DE", VIJF.Value) end if DFF then Datastore:SetAsync(tostring(player.userId)..":DF", ZES.Value) end if DGG then Datastore:SetAsync(tostring(player.userId)..":DG", ZEVEN.Value) end if DHH then Datastore:SetAsync(tostring(player.userId)..":DH", ACHT.Value) end if DII then Datastore:SetAsync(tostring(player.userId)..":DI", NEGEN.Value) end end end) end end game.Players.ChildAdded:connect(KOE) game.Workspace.ChildAdded:connect(VAR)
The only error that shows up is (" Script 'Workspace.Leaderboard', Line 111" Cannot write to DataStore from studio if API access is not enabled. Enable it by going to the Game Settings page.)
Thank you sorry for the confusing script.
Well, your script will most likely work, but not in studio. This error you have here:
(Script 'Workspace.Leaderboard', Line 111" Cannot write to DataStore from studio if API access is not enabled. Enable it by going to the Game Settings page.)
This isn't really an error, but more of a security check. You need to go to the place's game settings and enable API Access to DataStores for Studio. If you don't, then it'll only work in the actual game, and not ROBLOX Studio. But of course, we'd like to let it work in studio, so here's a 45 second clip of how to do that.
Good luck on your future Scripting Adventures! ~lightpower26