my datastore isn’t working, I enabled the “Enable Studio Access To API Services” for sure, my script:
local DataStore = game:GetService("DataStoreService")
local AddedNumber = DataStore:GetDataStore("AddedNumber")
script.Parent.ClickDetector.MouseClick:Connect(function()
local succes = pcall(function()
AddedNumber:SetAsync(script.Parent.Value.Value, script.Parent.Value.Value + 1)
end)
local success2 = pcall(function()
AddedNumber:SetAsync(script.Parent.SurfaceGui.TextLabel.Text, tostring(script.Parent.Value.Value))
end)
if succes and success2 then
AddedNumber:SetAsync(script.Parent.Value.Value, script.Parent.Value.Value + 1)
AddedNumber:SetAsync(script.Parent.SurfaceGui.TextLabel.Text, tostring(script.Parent.Value.Value))
end
end)
You’re kinda overusing the SetKey command. Which causes the datastore to enter the queue.
I guess what your doing is add a number on click. The better way is just checking if the number changed and save it into the datastore.
local DataStore = game:GetService("DataStoreService")
local AddedNumber = DataStore:GetDataStore("AddedNumber")
local ConvertTostring = DataStore:GetDataStore("ConvertTostring")
local Number = -- IntValue instance
script.Parent.ClickDetector.MouseClick:Connect(function()
Number.Value = Number.Value + 1
end)
Number:Changed(function())
Wait(6.0) -- due to write request limit.
AddedNumber:SetAsync(--Do whatever you want doe)
end)
To what am i seeing here is that you’re making a part to where when the player clicks, it will saves data twice, with a key and value that you don’t provide any explanation…