How can I make progress bar more slidely

As title says, how can I make progress bar more slidely (idk how to name it)? It is how it looks like now.


Script:

local function raycastThing(Part: Part, Player : Player, GUI)
	if raycastThingDB == true then return end
	raycastThingDB = true
	local capturedSeconds = Part:FindFirstChild("capturedSeconds")

	while capturedSeconds.Value < captureTime do
		if typeof(Part:GetTouchingParts()) == "table" and typeof(workspace:GetPartBoundsInBox(Part.CFrame, Part.Size)) == "table" then
			for _, part in ipairs(Part:GetTouchingParts()) do
				if Player.Character:IsAncestorOf(part) and table.find(workspace:GetPartBoundsInBox(Part.CFrame, Part.Size), part) then
					capturedSeconds.Value = capturedSeconds.Value + 1
					local progress_percent = capturedSeconds.Value/captureTime
					GUI.RobloxStyledTerminal.LeftFrame.PointBar.Size = UDim2.new(progress_percent, 0, 1, 0)
					break
				end
			end
		end
		task.wait(0.5)
	end
	raycastThingDB = false
end
3 Likes

I would recommend using TweenService in order to tween the bar. This will give it a much smoother aesthetic no matter the desired size of the filling bar.

2 Likes

Thank you for this. I have a little problem. I have never used tween on UI. I modified script to this

local function raycastThing(Part: Part, Player : Player, GUI)
	local Tweengoal = {}
	Tweengoal.Position = Vector2.new(1,1)
	if raycastThingDB == true then return end
	raycastThingDB = true
	local capturedSeconds = Part:FindFirstChild("capturedSeconds")
	local tween = game:GetService("TweenService"):Create(GUI.RobloxStyledTerminal.LeftFrame.PointBar, captureTime, Tweengoal)

	while capturedSeconds.Value < captureTime do
		if typeof(Part:GetTouchingParts()) == "table" and typeof(workspace:GetPartBoundsInBox(Part.CFrame, Part.Size)) == "table" then
			for _, part in ipairs(Part:GetTouchingParts()) do
				if Player.Character:IsAncestorOf(part) and table.find(workspace:GetPartBoundsInBox(Part.CFrame, Part.Size), part) then
					capturedSeconds.Value = capturedSeconds.Value + 1
					local progress_percent = capturedSeconds.Value/captureTime
					GUI.RobloxStyledTerminal.LeftFrame.PointBar.Size = UDim2.new(progress_percent, 0, 1, 0)
					tween:Play()
					break
				end
				tween:Pause()
			end
		end
		task.wait(0.5)
	end
	raycastThingDB = false
end

and whole part of this script stopped working. May you help me?

1 Like

You will need to set up a TweenInfo instance in order to tell TweenService how long your tween will last. There’s an example on how to use TweenService:Create() at the end of the section I’ve linked in my previous post.

Another thing you may need to take note of is, you will need to re-define your desired propertyGoals every time it changes. And as a result, create a new Tween. Which means you will need to determine it within the while-loop.

As I don’t know the rest of your code, my best guess integration would be this:

local TweenService = game:GetService('TweenService')
local function raycastThing(Part: Part, Player : Player, GUI)
	if raycastThingDB == true then return end
	raycastThingDB = true
	local capturedSeconds = Part:FindFirstChild("capturedSeconds")
	local tweenInfo = TweenInfo.new(0.2) -- Every time the bar changes, it will tween to the desired size over the span of 0.2 seconds

	while capturedSeconds.Value < captureTime do
		if typeof(Part:GetTouchingParts()) == "table" and typeof(workspace:GetPartBoundsInBox(Part.CFrame, Part.Size)) == "table" then
			for _, part in ipairs(Part:GetTouchingParts()) do
				if Player.Character:IsAncestorOf(part) and table.find(workspace:GetPartBoundsInBox(Part.CFrame, Part.Size), part) then
					capturedSeconds.Value = capturedSeconds.Value + 1
					local progress_percent = capturedSeconds.Value/captureTime
					local newTween = TweenService:Create(GUI.RobloxStyledTerminal.LeftFrame.PointBar, tweenInfo, {
						Size = UDim2.new(progress_percent, 0, 1, 0)
					})
					newTween:Play()
					break
				end
				tween:Pause()
			end
		end
		task.wait(0.5)
	end
	raycastThingDB = false
end
4 Likes

I get "Infinite yield possible on ā€˜CoreGui.RobloxGui:WaitForChild(ā€œModulesā€)’ " warning which really annoys me

This is unrelated and just a bug on Roblox’ side. the CoreGui is something we developers do not have any access to.

2 Likes

I have one last question. Can I change color of that GUI with tween when ā€œifā€ statement is true? (it isnt in script)

1 Like

Absolutely! You can tween any property of any object other than Object values, NumberRange, NumberSequence and ColorSequence. In case I’ve overlooked a type that isn’t supported as well, I apologise.

1 Like

This looks solved do you have any questions or errors about this?

1 Like

No, I do not have any problems, but thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.