How to make terminal progress bar

I have a script

local PointA = game.Workspace.A
local Raiders = game.Teams.Raiders
local Defenders = game.Teams.Defenders
local captureTime = 5
local capturedBy = nil

PointA.Touched:Connect(function(part)
	if PointA.Captureable.Value == true then
		local player = game:GetService("Players"):GetPlayerFromCharacter(part.Parent)
		if player then
			local PlayerGUI = player:FindFirstChild("PlayerGui")
			if player.TeamColor == Raiders.TeamColor and (capturedBy == nil or capturedBy == "Def") then
				capturedBy = "Raid"
				while PointA.Captureable.Value == true and PointA.Value.Value < 5 do
					PointA.Value.Value += 1
					wait(1)
					if capturedBy == "Def" then
						break
					end
				end
				if PointA.Value.Value == 5 then
					capturedBy = nil
					PointA.Captureable.Value = false
					PointB.Captureable.Value = true
				end
			elseif player.TeamColor == Defenders.TeamColor and capturedBy == "Raid" then
				capturedBy = "Def"
				while PointA.Captureable.Value == true and (PointA.Value.Value < 5 and PointA.Value.Value > 0) do
					PointA.Value.Value -= 1
					wait(1)
				end
			end
			PointA.Value.Changed:Connect(function()
				if PlayerGUI then
					local pointsLabel = PlayerGUI:FindFirstChild("Points")
					if pointsLabel then
						pointsLabel.A.Text = tostring(PointA.Value.Value) .. " / 400"
					end
				end
			end)
		end
	end
end)

I need, so progress bar (picture 1) shows progress how much did defenders/raiders captured terminal. It takes 5 seconds to capture terminal. Terminal GUI hierarchy in picture 2 (if you need it)

picture 1

picture 2
2323

set the size to UDim2.new(currentvalue/endpoint,0,1,0)

in what place in script should i place it?

You need 2 things, the time it takes to capture the point (your captureTime), and how long the raiders have been capturing the point for (let’s call it capturingTime and let’s say it’s equal to 2.3 seconds)
Once you have these 2 you divide capturingTime by captureTime.

local progress_percent = capturingTime / captureTime -- in this example it will be: 2.3/5 so 0.46

this will give you the percantage value (how “captured” the point is).
Then you need to go to the progress bar and just set the X scale size to the percent value.

progressbar.Size = UDim2.new(progress_percent, 0, 1, 0)
1 Like

I just realized, how to implement that into script? .Touched event only takes when player touched part. I want so it check when player is standing on it

You can use spatial queries for example

and what is that?

asdsaafdsgfdgdzdgfd

what about using raycasting? would that also work?