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
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.
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?
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
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.