I have a problem with my chests system

Well what happens, when the player is added, i’m assuming you’ve already set up the cooldown. Basically, when the player joins the game, you check if the cooldown is over, and if it is, then you do what I said from there

1 Like

I’ll try it out, but as of now, that is the solution :smiley:

Basically, for example, let’s say this is where you have your datastore:

local ds = game:GetService("DataStoreService")
local opened = ds:GetDataStore("Opened")

game.Players.PlayerAdded:Connect(function(player)
    local claim = Instance.new("BoolValue",player)
    claim.Name = "Opened"
    claim.Value = false

    local storeclaim

    local success, errormessage = pcall(function()
		storeclaim = MinuteStore:GetAsync(Player.userId.."-Opened")
    end)
	
	if success then
		claim.Value = storeclaim
	else
		print("There was an error while getting data.")
		warn(errormessage)
	end

    if claim.Value == false then
        --fire remote event to change textlabel and such
    end

    claim:GetPropertyChangedSignal("Value"):Connect(function()
        if claim.Value == true then
            --start cooldown here
        end
    end)
end)

game.Players.PlayerRemoving:Connect(function(player)
	local success, errormessage = pcall(function()
		opened:SetAsync(player.userId.."-Opened", player:FindFirstChild("Opened").Value)
	end)
	
	if success then
		print("Data was successfully stored!")
	else
		print("There was an error while storing data.")
		warn(errormessage)
	end
end)