XxAkaDuyxX
(XxAkaDuyxX)
February 5, 2021, 5:17am
#1
I am new to using Datastore2. Why doesn’t my save work?
local events = Instance.new("Folder")
events.Name = "Events"
events.Parent = game:WaitForChild("ServerStorage")
datastore2.Combine("Wins")
game.Players.PlayerAdded:Connect(function(playeradded)
local wins = datastore2("Wins", playeradded)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "Data"
leaderstats.Parent = playeradded
local actualleaderstats = leaderstats:Clone()
actualleaderstats.Name = "leaderstats"
actualleaderstats.Parent = playeradded
local winsstat = Instance.new("NumberValue")
winsstat.Name = "Wins"
winsstat.Parent = leaderstats
winsstat:Clone().Parent = actualleaderstats
winsstat.Value = wins:Get(0)
wins:OnUpdate(function(newWins)
game.Players[playeradded.Name].Data.Wins.Value = newWins
game.Players[playeradded.Name].leaderstats.Wins.Value = newWins
end)
end)
Please someone at least help me with this script, I can’t wait long.
Maybe have to do with the fact that it’s not saving because it has not changed from the original value.
XxAkaDuyxX
(XxAkaDuyxX)
February 5, 2021, 9:52am
#3
I don’t think it’s the original value that I changed.
XxAkaDuyxX
(XxAkaDuyxX)
February 5, 2021, 11:15am
#4
Can someone please help me ://
try this one
local DataStore2 = require(1936396537)
local events = Instance.new("Folder")
events.Name = "Events"
events.Parent = game:WaitForChild("ServerStorage")
DataStore2.Combine("MasterKey","Wins")
game.Players.PlayerAdded:Connect(function(playeradded)
local wins = DataStore2("Wins", playeradded)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "Data"
leaderstats.Parent = playeradded
local actualleaderstats = leaderstats:Clone()
actualleaderstats.Name = "leaderstats"
actualleaderstats.Parent = playeradded
local winsstat = Instance.new("NumberValue")
winsstat.Name = "Wins"
winsstat.Parent = leaderstats
winsstat:Clone().Parent = actualleaderstats
winsstat.Value = wins:Get(0)
wins:OnUpdate(function(newWins)
game.Players[playeradded.Name].Data.Wins.Value = newWins
game.Players[playeradded.Name].leaderstats.Wins.Value = newWins
end)
end)
XxAkaDuyxX
(XxAkaDuyxX)
February 5, 2021, 1:59pm
#7
It doesn’t save though, (SaveInStudio is on) and API Service is on too.
how bout this one
local DataStore2 = require(1936396537)
local events = Instance.new("Folder")
events.Name = "Events"
events.Parent = game:WaitForChild("ServerStorage")
DataStore2.Combine("Wins")
game.Players.PlayerAdded:Connect(function(plr)
local wins = DataStore2("Wins",plr)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "Data"
leaderstats.Parent = playeradded
local actualleaderstats = leaderstats:Clone()
actualleaderstats.Name = "leaderstats"
actualleaderstats.Parent = playeradded
local winsstat = Instance.new("NumberValue")
winsstat.Name = "Wins"
winsstat.Parent = leaderstats
winsstat:Clone().Parent = actualleaderstats
winsstat.Value = wins:Get(0)
wins:OnUpdate(function(newWins)
game.Players[playeradded.Name].Data.Wins.Value = newWins
game.Players[playeradded.Name].leaderstats.Wins.Value = newWins
end)
end)
XxAkaDuyxX
(XxAkaDuyxX)
February 6, 2021, 5:46am
#9
Still doesn’t work either though
angrybino
(angrybino)
February 6, 2021, 6:06am
#10
DataStore2 won’t save values that weren’t updated, this is to prevent consuming unnecessary data store budget. In your case, since you never seem to be updating wins, there is no need to save it, you will have to update it in order for DataStore2 to save it.
XxAkaDuyxX
(XxAkaDuyxX)
February 6, 2021, 6:09am
#11
How can I make it save if it doesn’t save?
XxAkaDuyxX
(XxAkaDuyxX)
February 7, 2021, 1:06am
#13
Why is no one helping me…???
We’re trying, try just using regular datastore instead if you can help it.
XxAkaDuyxX
(XxAkaDuyxX)
February 7, 2021, 1:20am
#15
I prefer DataStore2 instead of regular datastore because of less bad consequences.
1 Like
XxAkaDuyxX
(XxAkaDuyxX)
February 7, 2021, 4:03am
#16
I still need help just to let you know…
XxAkaDuyxX
(XxAkaDuyxX)
February 7, 2021, 4:34am
#18
The script is the main script I’m using for updating and creating the Wins as leaderstats, and the module script as DataStore2.
why don’t you use a regular datastore
the regular datastore is easier
XxAkaDuyxX
(XxAkaDuyxX)
February 7, 2021, 5:15am
#20
Like what I said from above, I prefer DataStore2 instead of regular datastore because of less bad consequences, which is I don’t want players to complain if they lose data automatically since they can lose data, which I know I can do that too but, I still prefer using this.
may I modify the script??
(ignore this)
XxAkaDuyxX
(XxAkaDuyxX)
February 7, 2021, 7:29am
#22
Yes you can but what script specifically?
I want to change the script a little bit