I tested your script and it works. Since that part is functioning correctly, the issue may potentially lie within this script:
game.ReplicatedStorage.tasks.h2.OnServerEvent:Connect(function(player, newCoins)
local taskk = player:WaitForChild("tasks")
local taskk2 = saunat:FindFirstChild("ht2")
wait(.5)
taskk2.Value = newCoins
end)
This script locates here:
As I mentioned, the “allsaves” script notifies the datastore script when a specific value has changed and then saves the new value to the datastore. The reason it needs to inform the datastore about the change is that the “taskscript” is a local script.
I attempted to implement this system, but the issue remains the same:
local function updateHours2(value)
wait(.5)
ht2.Value += 1
h2:FireServer(ht2.Value)
local seconds = value
local hours = seconds / 3600
local formattedHours = string.format("%.1f h", hours)
return formattedHours
end
and
ht2.Changed:Connect(function()
wait(.5)
...
elseif hr2.Value == 5 then
if ht2.Value >= 36000 then
coin.Value = coin.Value + 1000000000
coe:FireServer(coin.Value)
hteht = 2 --this just tells, which textlabel shows the task
hr2.Value = 0
ht2.Value = 0
wait()
hdone = 'Be online for 10 hours' --this just tells player which task player completed
done()-- this shows frame with the task what you have completed
vaikeus = 3 -- "vaikeus" means "difficulty"
t2.task2.Text = "x"
else
if vaikeus == 3 then
t2.task2.Text = hourht2 .. "/ 10h"
end
hourht2 = updateHours2(ht2.Value)
end
...
end)
if hr2.Value == 5 then
hourht2 = updateHours2(ht2.Value)
print("ht2 started")
end
Here is the whole code with the translations because I live in Finland and I like to use finnish words in the code. Because it’s too long and hard to read in here, I made a link. Here it is:
Edit: This is annoying bug because it’s simple bug but hard to fix it. Hopefully we can find the solution for this problem