hello, I have been working for a long time using the DataStore2 system, I basically already know how to use it, but lately a script of my “Quest” is not working before, it used to work normally …
it seems that for some reason it is not reading the increment part in the script, I can get the value of :Get ()
but I can’t change a value in the script using :Increment ()
and :Set ()
this is my script [Server Script] (It can be a bit confusing but I hope you can understand)
local DataStore2 = require(5159892169) --This is my module OBS: (Updated Version!)
local ConverValues = require(5084840082)
DataStore2.Combine("GameData_V1","Power","TotalPower","Rebirth")
local localplayer = script.Parent.Parent.Parent.Parent
--Remotes--
local Remote = script.RemoteEvent
local KilledDummy = game.ReplicatedStorage.Events.Giver_Event
local UpdatedPowerEvent = game.ReplicatedStorage.Events.Update_UIPower
local CompletedQuestEvent = game.ReplicatedStorage.Events.QuestCompletedEventGive
---------------
local QuestFrame = script.Parent.Parent.QuestFrame
local Kills = nil
local NumberKills = nil
local QuestDummy = nil
local DummyNameInQuest = nil
local GiverAmountPower = nil
local HaveQuest = false
Remote.OnServerEvent:Connect(function(player,DummyName,DummyNameQuest,ToKills,ValueToGive)
if player.Name == localplayer.Name then
local RebirthSave = DataStore2("Rebirth",game.Players[player.Name])
QuestFrame:TweenPosition(UDim2.fromScale(1,0.95),'Out', 'Bounce', 1,true)
HaveQuest = true
GiverAmountPower = (tonumber(ValueToGive)*(RebirthSave:Get(0)+1))
QuestDummy = DummyName
DummyNameInQuest = DummyNameQuest
Kills = 0
NumberKills = ToKills
local TextQuest = "Kill "..ToKills.." "..DummyNameQuest.." to earn "..ConverValues:ConvertShort(GiverAmountPower)
QuestFrame.QuestInfo.Text = TextQuest
QuestFrame.QuestKills.Kill_Amount.Text = Kills.."/"..ToKills
QuestFrame.QuestKills.QuestBar.Size = UDim2.fromScale(0,1)
end
end)
function QuestFinished()
local random = math.random(250, 750)
local xnew = random / 1000
local new = script:WaitForChild("PowerGived"):Clone()
new.Text = "💪+".. ConverValues:ConvertShort(GiverAmountPower)
new.Position = UDim2.new(xnew, 0, 1, 0)
new.Parent = script.Parent.Parent
new:TweenPosition(UDim2.new(new.Position.X,0,0,0),'Out', 'Linear', 1)
QuestFrame:TweenPosition(UDim2.fromScale(1,1.95),'Out', 'Bounce', 1,true)
HaveQuest = false
GiverAmountPower = nil
QuestDummy = nil
DummyNameInQuest = nil
Kills = nil
NumberKills = nil
wait(4)
new:Destroy()
end
local function FinishQuest()
QuestFrame:TweenPosition(UDim2.fromScale(1,1.95),'Out', 'Bounce', 1,true)
wait()
HaveQuest = false
GiverAmountPower = nil
QuestDummy = nil
DummyNameInQuest = nil
Kills = nil
NumberKills = nil
end
script.FinishQuest.OnServerEvent:Connect(FinishQuest)
KilledDummy.Event:Connect(function(PlayerName,DummyKilledName)
if HaveQuest then
if PlayerName == localplayer.Name then
if DummyKilledName == QuestDummy then
Kills = Kills+1
local TextQuest = "Kill "..NumberKills.." "..DummyNameInQuest.." to earn "..ConverValues:ConvertShort(GiverAmountPower)
QuestFrame.QuestInfo.Text = TextQuest
QuestFrame.QuestKills.Kill_Amount.Text = Kills.."/"..NumberKills
local BarSize = Kills/NumberKills
QuestFrame.QuestKills.QuestBar:TweenSize(UDim2.fromScale(BarSize,1),'In', 'Quint', 0.5, true)
if Kills == NumberKills then
local PowerSave = DataStore2("Power",game.Players[PlayerName])
local TotalPowerSave = DataStore2("TotalPower",game.Players[PlayerName])
PowerSave:Increment(GiverAmountPower,0) -- For some reason these lines are not being executed by datastore2
TotalPowerSave:Increment(GiverAmountPower,0) -- For some reason these lines are not being executed by datastore2
QuestFinished()
end
end
end
end
end)