Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

can i get help with a rpg datastore script?

Asked by 5 years ago
Edited 5 years ago

i need some help with a level up system in my rpg datastore error: "03:24:51.587 - DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = 96434321"

local ds = game:GetService("DataStoreService")
local leveldata = ds:GetDataStore("level")
local expdata = ds:GetDataStore("exp")
local golddata = ds:GetDataStore("gold")

game.Players.PlayerAdded:Connect(function(plr)
        local stats = Instance.new("Accessory")
        stats.Name = "stats"
        stats.Parent = plr

        local level = Instance.new("IntValue")
        level.Name = "level"
        level.Parent = stats
        level.Value = leveldata:GetAsync(plr.UserId) or 1

        local exp = Instance.new("IntValue")
        exp.Name = "exp"
        exp.Parent = stats
        exp.Value = expdata:GetAsync(plr.UserId) or 0

        local gold = Instance.new("IntValue")
        gold.Name = "gold"
        gold.Parent = stats
        gold.Value = golddata:GetAsync(plr.UserId) or 0

        level.Changed:Connect(function()
            leveldata:SetAsync(plr.UserId,level.Value)
        end)
        exp.Changed:Connect(function()
            expdata:SetAsync(plr.UserId,exp.Value)
        end)
        gold.Changed:Connect(function()
            golddata:SetAsync(plr.UserId,gold.Value)
        end)

        game.Players.PlayerRemoving:Connect(function()
                leveldata:SetAsync(plr.UserId,level.Value)
                expdata:SetAsync(plr.UserId,exp.Value)
                golddata:SetAsync(plr.UserId,gold.Value)
        end)

        while wait(30) do
                leveldata:SetAsync(plr.UserId,level.Value)
                expdata:SetAsync(plr.UserId,exp.Value)
                golddata:SetAsync(plr.UserId,gold.Value)
        end

        local function levelup()
                while wait(0.09) do


                        local hum = plr.Character:WaitForChild("Humanoid")

                        exp.Value = exp.Value - level.Value * 100
                        level.Value = level.Value + 1
                        hum.MaxHealth = hum.MaxHealth + 10
                        hum.Health = hum.MaxHealth
                end
        end
        level.Changed:Connect(function()wait() levelup()end)
        exp.Changed:Connect(function()wait() levelup()end)
end)
0
Try putting those stats,levels gold etc into a table then saving the table. Andromeda0161 0 — 5y
0
@Andromeda0161 i have no clue how to use tables! RecycleBicycle 60 — 5y
0
also @andromeda0161 im not trying to save im trying to make the level stat go highter RecycleBicycle 60 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

everyone I fixed it myself! :) also here is the local script that I use that's inside the PlayerGui

local s = script.Parent.Parent.stats

while wait(0.09) do
        if s.exp.Value >= s.level.Value * 100 then
                s.exp.Value = 0
                s.level.Value = s.level.Value + 1
        end
end

also, I'm looking for a more reliable script!

Ad

Answer this question