Hi,
I am making a game, Dangerous DJs, Dangerous DJs - Roblox, and I need help with saving the players’ data. (Around 281 values, and it gives me overflow errors, which stops some data from being saved.)
I have searched around on google and the DevForum, tried putting wait() commands to slow down the datastore requests, and I haven’t been able to find a solution. The reason I need to save so many values, is that the players can create their own beats and melodies, and I want them to save. It takes a bit of time to make the beats, and other systems in the game rely on the saved stats.
Here is one of my scripts that is supposed to save 16 values:
--Save:
game.Players.PlayerRemoving:connect(function(player)
local datastore = game:GetService("DataStoreService"):GetDataStore(player.Name.."Loop1")
local statstorage = player:FindFirstChild("Loop1"):GetChildren()
for i = 1, #statstorage do
datastore:SetAsync(statstorage[i].Name, statstorage[i].Value)
print("saved data number "..i)
end
print("Stats successfully saved")
end)
--Load:
game.Players.PlayerAdded:connect(function(player)
wait(2.5)
local datastore = game:GetService("DataStoreService"):GetDataStore(player.Name.."Loop1")
player:WaitForChild("Loop1")
wait(1)
local stats = player:FindFirstChild("Loop1"):GetChildren()
for i = 1, #stats do
stats[i].Value = datastore:GetAsync(stats[i].Name)
print("stat numba "..i.." has been found")
end
end)
This is a video of one of the systems that needs to have saved stats (Sorry about bad quality and audio lag, I was using the Roblox screen recording system):
Demo.wmv (2.1 MB)
Each of those tiles/notes will be represented as a string value, with the name the tile number, and the value the sound that it is supposed to play.
Also, I am having a problem where the tiles that play a sound take a bit longer than the tiles that dont play a sound.
Example:
Demo2.wmv (1.2 MB)
The blue outline indicates what tile is playing.
Here is the script that plays the notes:
--Tracks:------------------------------------------------------------------------------------------------------------------
track1 = script.Parent.Parent.Parent.Track1Buttons
track2 = script.Parent.Parent.Parent.Track2Buttons
--Track 1 function:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function play1()
--Player:----------------------------------------------------------------------------------------------------------------
local plr = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent
--Find the charater and sounds:------------------------------------------------------------------------------------------
local char = game.Workspace:FindFirstChild(plr.Name)
local sawpart = char:FindFirstChild("SawWaveSoundPart")
local synthpart = char:FindFirstChild("BeepSoundPart")
local errorpart = char:FindFirstChild("ErrorWaveSoundPart")
--Find the buttons that are on:-------------------------------------------------------------------------------------------
for index, button in pairs(track1:GetChildren()) do
if button.ClassName == "TextButton" then
if button.Text ~= "Empty (click to change)" then
--Find the note:-------------------------------------------------------------------------------------------------
for notes, note in pairs(button.Notes:GetChildren()) do
if note.Value == true then
notename = note.Name
end
end
if button.Synth.Value == true then
--Find the sound and play it:----------------------------------------------------------------------------------
local sound = synthpart:FindFirstChild("Beep"..notename)
button.BorderColor3 = Color3.new(0,0,255)
sound.TimePosition = 0
sound.Volume = .5
sound.Playing = true
wait(.17)
sound.Volume = .4
wait(.02)
sound.Volume = .3
wait(.02)
sound.Volume = .2
wait(.02)
sound.Volume = .1
wait(.02)
sound.Playing = false
button.BorderColor3 = Color3.new(0,255,0)
elseif button.Saw.Value == true then
--Find the sound and play it:----------------------------------------------------------------------------------
local sound = sawpart:FindFirstChild("SawWave"..notename)
button.BorderColor3 = Color3.new(0,0,255)
sound.TimePosition = 0
sound.Volume = .5
sound.Playing = true
wait(.17)
sound.Volume = .4
wait(.02)
sound.Volume = .3
wait(.02)
sound.Volume = .2
wait(.02)
sound.Volume = .1
wait(.02)
sound.Playing = false
button.BorderColor3 = Color3.new(0,255,0)
elseif button.Error.Value == true then
--Find the sound and play it:----------------------------------------------------------------------------------
local sound = errorpart:FindFirstChild("ErrorWave"..notename)
button.BorderColor3 = Color3.new(0,0,255)
sound.TimePosition = 0
sound.Volume = .5
sound.Playing = true
wait(.17)
sound.Volume = .4
wait(.02)
sound.Volume = .3
wait(.02)
sound.Volume = .2
wait(.02)
sound.Volume = .1
wait(.02)
sound.Playing = false
end
else
--If empty, wait:------------------------------------------------------------------------------------------------
button.BorderColor3 = Color3.new(0,0,255)
wait(.25)
button.BorderColor3 = Color3.new(0,255,0)
end
end
end
end
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--Track 2 function:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function play2()
--Player:----------------------------------------------------------------------------------------------------------------
local plr = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent
--Find the charater and sounds:------------------------------------------------------------------------------------------
local char = game.Workspace:FindFirstChild(plr.Name)
local sawpart = char:FindFirstChild("SawWaveSoundPart")
local synthpart = char:FindFirstChild("BeepSoundPart")
local errorpart = char:FindFirstChild("ErrorWaveSoundPart")
--Find the buttons that are on:-------------------------------------------------------------------------------------------
for index, button in pairs(track2:GetChildren()) do
if button.ClassName == "TextButton" then
if button.Text ~= "Empty (click to change)" then
--Find the note:-------------------------------------------------------------------------------------------------
for notes, note in pairs(button.Notes:GetChildren()) do
if note.Value == true then
notename = note.Name
end
end
if button.Synth.Value == true then
--Find the sound and play it:----------------------------------------------------------------------------------
local sound = synthpart:FindFirstChild("Beep"..notename)
button.BorderColor3 = Color3.new(0,0,255)
sound.TimePosition = 0
sound.Volume = .5
sound.Playing = true
wait(.17)
sound.Volume = .4
wait(.02)
sound.Volume = .3
wait(.02)
sound.Volume = .2
wait(.02)
sound.Volume = .1
wait(.02)
sound.Playing = false
button.BorderColor3 = Color3.new(0,255,0)
elseif button.Saw.Value == true then
--Find the sound and play it:----------------------------------------------------------------------------------
local sound = sawpart:FindFirstChild("SawWave"..notename)
button.BorderColor3 = Color3.new(0,0,255)
sound.TimePosition = 0
sound.Volume = .5
sound.Playing = true
wait(.17)
sound.Volume = .4
wait(.02)
sound.Volume = .3
wait(.02)
sound.Volume = .2
wait(.02)
sound.Volume = .1
wait(.02)
sound.Playing = false
button.BorderColor3 = Color3.new(0,255,0)
elseif button.Error.Value == true then
--Find the sound and play it:----------------------------------------------------------------------------------
local sound = errorpart:FindFirstChild("ErrorWave"..notename)
button.BorderColor3 = Color3.new(0,0,255)
sound.TimePosition = 0
sound.Volume = .5
sound.Playing = true
wait(.17)
sound.Volume = .4
wait(.02)
sound.Volume = .3
wait(.02)
sound.Volume = .2
wait(.02)
sound.Volume = .1
wait(.02)
sound.Playing = false
button.BorderColor3 = Color3.new(0,255,0)
end
else
--If empty, wait:------------------------------------------------------------------------------------------------
button.BorderColor3 = Color3.new(0,0,255)
wait(.25)
button.BorderColor3 = Color3.new(0,255,0)
end
end
end
end
script.Parent.MouseButton1Click:Connect(play1)
script.Parent.MouseButton1Click:Connect(play2)
Thanks for reading, and sorry for the long post. Thanks! 
