Hello, I have this problem with my script inside of a gui. Whenever I click on the gui, it adds 100k to my value which is then saved when I leave the game. However, when I rejoin, the value I had did not actually save and reverts back to the value before I clicked on the gui.
I’m pretty sure my datastore script is fine, but the gui instead.
Example:
Join → 0
Click on gui —> Value = 100k
Rejoin —> 0
local player = game.Players.LocalPlayer
local data1 = player:WaitForChild("Data1")
local data2 = player:WaitForChild("Data2")
local leaderstats = player:WaitForChild("leaderstats")
local pets = player:WaitForChild("Pets")
local UC = data1:WaitForChild("UncookedChiikens")
local Multiplier = data2:WaitForChild("Multiplier")
local CC = pets:WaitForChild("CommonChiiken")
local RC = pets:WaitForChild("RareChiiken")
local EC = pets:WaitForChild("EpicChiiken")
local Chiikens = leaderstats:WaitForChild("Chiikens")
local gui = script.Parent.Parent.Parent
local bg = gui.WarningBG
local notown = bg.NotOwn
local freebie = bg.Freebie
local debounce = false
script.Parent.MouseButton1Click:Connect(function()
if CC.Value == true then
if debounce == false then
debounce = true
UC.Value += 100000
wait(5)
debounce = false
return
end
else
if debounce == false then
bg.Visible = true
notown.Visible = true
debounce = true
wait(5)
bg.Visible = false
notown.Visible = false
debounce = false
end
end
if CC.Value == true and RC.Value == true then
if debounce == false then
debounce = true
UC.Value += 10100000
wait(3)
debounce = false
return
end
else
if debounce == false then
bg.Visible = true
notown.Visible = true
debounce = true
wait(5)
bg.Visible = false
notown.Visible = false
debounce = false
end
end
if CC.Value == true and RC.Value == true and EC.Value == true then
if debounce == false then
debounce = true
UC.Value += 65100000
Multiplier.Value += 25
wait(15)
debounce = false
return
end
else
if debounce == false then
bg.Visible = true
notown.Visible = true
debounce = true
wait(5)
bg.Visible = false
notown.Visible = false
debounce = false
end
end
end)