Gui Disabling Glitch

I have a UI (Basically a progress bar for destroying objects) that after each time it is enabled, it will disable itself after 15 seconds.

The problem is that if the player is still destroying things (meaning the progress bar is still being activated), and the 15 seconds have passed, it will keep just de activating and activating on each time until the player stops activating it.

Here is a video on the situation:

External Media

The only solution i can think of is making it turn off after the latest activation, but idk how to do that.

Thanks for the help :slight_smile:

1 Like

Can you send the code you used for the progress bar? it would be alot helpful to understand the problem if you sent it.

1 Like
-- the functions aren't related to the progress bar, just other things

event.OnClientEvent:Connect(function(part, minus)
	if part:IsA("Terrain") == false then
		active = true

		local hp:number = UIFunction.GetHp(part)

		local maxHp = UIFunction.getMaxHp(part)

		if hp then UIFunction.Damage(part, minus, hp) end
		UIFunction.UpdateUI(part.Name, maxHp, hp) -- this one just enables it thats it

		if hp == 0 then
			UIFunction.Finish(part)
		end

		wait(15)

		player.PlayerGui:WaitForChild("BreakingBar").Enabled = false
	end
end)
1 Like

im a newbie but have you tried putting the

wait(15)

player.PlayerGui:WaitForChild(“BreakingBar”).Enabled = false

inside the

if hp == 0 then
UIFunction.Finish(part)
end

i dont know if this will work because i dont know how often the function gets fired

1 Like

this would do the same thing as the unchanged script but i appreciate the help :slight_smile:

1 Like

What is the server script doing apart from calling the client?

The only thing it does is call the client with the parameters of what part (the part is whatever part is being damaged) and how much damage (which is minus). The server script doesn’t matter tho. All it needs is a way to disable after the last activation, not anything to do with the actual server script and function

I guess then use a boolean to check if part is available to be destroyed.

I cant understand the whole system with just this script. Try making a bool value called “PartDestroyed” and if the part is destroyed make it set to false. and check if the value is false it makes the gui disabled Im not sure if thats what your going for though.