Hey, Ive recently been working on a small game project of mine. I wanted to add boost potions to the game but i dont really know how, i did something like this:
local DataCache = require(game.ServerScriptService.DataCache)
game.Players.PlayerAdded:Connect(function(player)
wait(8)
local function countdownBoostDuration(boostType)
while wait(1) do
local Data = DataCache.GetDataFrom(player)
local boostDuration = player.Data.Boosts[boostType].Duration.Value
if boostDuration > 0 then
boostDuration -= 10
player.Data.Boosts[boostType].Duration.Value = boostDuration
print(player.Name .. "'s " .. boostType .. " Duration: " .. player.Data.Boosts[boostType].Duration.Value)
if boostDuration == 0 then
print("No more " .. boostType .. " boosts")
break
end
end
end
end
for boostType, boostData in pairs(player.Data.Boosts:GetChildren()) do
if boostData:IsA("IntValue") or boostData:IsA("NumberValue") then
countdownBoostDuration(boostType)
end
end
end)
But im sure this isnt the way, if you think you can help me please do so!