So, if you do not know, to capture terminal, you need in terminal’s range for x seconds. I want to make it, so when player stands inside it, progress bar is getting fulled and ocne it is full, it gets removed and points for team gets added
You’ll need a local script detecting nearby terminals every X seconds, once a terminal is detected make it fire the server once, then make the server keep track and check every Y seconds if the player is close enough to the terminal, once the player has passed enough time close to the terminal, make the server add points and delete the terminal, the progress bar can be handled on client by getting the initial seconds and periodically updating the bar until the terminal is captured.
Well, by capturing terminal progress bar I meant something like this:
When player in for example raider team enters terminal hitbox, it gets full
Yeah that’s what I meant, you could just add an attribute to the terminal containing the seconds required to capture the terminal and do that on client.
Yeah ok, but what to use to make it work? Tweens?
I suppose you want a mechanic similar to Capture the Point or King of the Hill, right?
First, you create the zone to be captured. Make it non collideable and anchored.
Then, you should store a IntConstrainedValue somewhere, it will represent the capture progress. I’ll call it ‘ZoneCapture’.
Use a normal script to detect if anyone is inside, and add points for each player inside to the value, at a frequency you desire.
When Value == MaxValue
, do what the you want the game to do when the zone is captured; be it victory, dissolution of the zone, etc etc. Use the .Changed
event.
As for the progress bar, do the following: Make a frame, and inside of it another one. The parent frame is the ‘case’ or ‘holder’ or whatever you want to call it. The child frame is the ‘percent’. The child frame’s size should be updated to something like this:
Percent.Size = UDim2.new(ZoneCapture.Value / ZoneCapture.MaxValue,0,1,0)
Any division can be interpreted as a percentage. 20/100, 40/200, 1/5, all of these mean 20%. Do the same to the ZoneCapture value and maxvalue. UDim2’s 1st and 3rd numbers mean size in percentage, thus Percent frame will fill the Parent frame according to such. Since you want a horizontal percent bar, you need only to vary the 1st parameter of the Size.
You have two ways to schedule the updates. One is to do it every single frame. The other is to do it everytime the ZoneCapture value changes, and this allows you to tween it using Percent:TweenSize
rather than Percent.Size
.
A UIPadding might also be good. Add it to the Parent frame.
I hope this helps.