-
What do you want to achieve?
I want to make every potion to do -1 value each seconds -
What is the issue?
It’s only working on the first value of the array -
What solutions have you tried so far?
I’ve tried rewriting my script and it simply didn’t work every single time.
This is a video to show you what I mean:
it doesn’t go down by one but this is not the issue im trying to fix.
I would prefer if it would do that on every single potions I’ve in the currentPotionWithTime table.
This is my client script code:
for i, v in pairs(currentPotionWithTime) do -- table
if i ~= nil then
while true do
for i = 1, #currentPotionWithTime do
timerNeedAddition = v.Name -- name of the potion
currentTime = v.Value -- value of the potion
print(currentTime) -- works
currentFrame = potionContainer:FindFirstChild(timerNeedAddition).RealFrame.MainframePotion.TimeRemaingingFrame
task.wait(waitTime) -- task.wait(1)
for potionTime = currentTime, 0, -1 do
local TIME_CHANGE_SIZE = potionTime / currentTime -- Making the bar go from left to right
-- Tweening the bar
tweenService:Create(currentFrame.CurrentTime, TweenInfo.new(tweenTimeBarDown), {Size = UDim2.new(TIME_CHANGE_SIZE, 0, 1, 0)}):Play()
currentFrame.CurrentText.Text = potionTime
potionTimerGoesDownEvent:FireServer(timerNeedAddition) -- remotes event puting -1 to the timer value
if currentTime <= 0 then -- if the value of the timer is <= 0 then it'll remove it from the table
for i = 1, #currentPotionWithTime do
if currentPotionWithTime[potionTime] == v then
table.remove(currentPotionWithTime, i)
end
end
currentFrame.CurrentText.Text = "No Potion Time"
end
end
end
task.wait(1)
end
end
end