Bar going wrong way

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I kick bar for a soccer game

  2. What is the issue? Include screenshots / videos if possible!

the bar is going from top to bottom. I want it to go from bottom to top

  1. What solutions have you tried so far? Did you look for solutions on the Creator Hub?
    I have tried reversing the values a ton and it did not work ):

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

here is the function

function resizeCustomLoadingBar(sizeRatio, clipping, top)

	clipping.Size = UDim2.new(clipping.Size.X.Scale, clipping.Size.X.Offset, sizeRatio, clipping.Size.Y.Offset)
	
	top.Size = UDim2.new(top.Size.X.Scale, top.Size.X.Offset, (sizeRatio > 0 and 1 / sizeRatio) or 0, top.Size.Y.Offset)
	
end

here is where i call it

local function updateBar()
	
	local barRatio = kickValue / finalYScale
	
	resizeCustomLoadingBar(barRatio, bar, top)
	
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

hey there, can you provide the hierarchical setup you have for your gui? perhaps try setting the clipping’s anchor point to 0, 1 and its y position scale to 1

1 Like

here

alright so im guessing that kickbar is the outline, clipping is an invisible frame that is used to clip the actually bar fill (with clip descendant instances) and top is that actual fill. have you tried changing the anchor point as i suggested?

which anchor point. Like which part of the ui

Change the anchor point of Top (which is supposedly the fill) to x = 0 y = 1 that should fix it

change anchor point to Vector2.new(0, 1) and y position to 1

it just does not show anymore
image


this is what happens

works for me, you probably did something wrong

Random question, but did you try using the Rotation property on the parent frame to just flip it upside down?

No I can. Lemme test it rn one second

No it did not work all it does is make the bar just fill fully in a instant

wanna send the ui as a rbxm file

All i did was change anchor point of top to 0,1 and then change position to 0,0,1,0

I cant I’m working for someone else rn and dont wanna give out the ui in case

make sure the code doesn’t change the position itself, and rotation is 0

do you need the code? I didn’t want to send bc its almost 200 lines of code

ok

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local UserInputService = game:GetService("UserInputService")

local Events = game.ReplicatedStorage:WaitForChild("Events")

local rs = game:GetService("ReplicatedStorage")
local modulesFolder = rs:WaitForChild("Modules")

local player = Players.LocalPlayer
local playerGUI = player:WaitForChild("PlayerGui")

local kickBar = playerGUI:WaitForChild("ScreenGui").KickBar
local bar = kickBar.KickBar.Clipping
local top = bar.Top
local weldLock = false

local startSize = bar.Size
local finalYScale = 1
bar.Size = startSize

local kickDistance = 10
local kickValue = 0
local kickIncreaseRate = 2

local debounce = false
local isKicking = false
local animFrozen = false

local ball = workspace:WaitForChild("Ball")

local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator") or Instance.new("Animator", humanoid)
local animation = animator:LoadAnimation(script.Animation)
animation.Looped = false
local rootPart = character:WaitForChild("HumanoidRootPart")

local camera = workspace.CurrentCamera
local clickedMouseB1 = false

local defaultFOV = camera.FieldOfView
local kickFOV = defaultFOV - 15
local tweenTime = 1

local remoteKick = Events.KickEvent
local remoteWeldBall = Events.WeldBall

local weldDistance = 4
local weldCooldown = false
local inputting = false

local fovTween = nil

local originalWalkSpeed = 26
local kickSlowSpeed = 8

function resizeCustomLoadingBar(sizeRatio, clipping, top)

	clipping.Size = UDim2.new(clipping.Size.X.Scale, clipping.Size.X.Offset, sizeRatio, clipping.Size.Y.Offset)
	
	top.Size = UDim2.new(top.Size.X.Scale, top.Size.X.Offset, (sizeRatio > 0 and 1 / sizeRatio) or 0, top.Size.Y.Offset)
	
end

local function tweenFOV(target)
	if fovTween then fovTween:Cancel() end
	local tweenInfo = TweenInfo.new(tweenTime, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
	local goal = { FieldOfView = target }
	fovTween = TweenService:Create(camera, tweenInfo, goal)
	fovTween:Play()
end

local function getLookUpAngle()
	local vertVector = camera.CFrame.LookVector
	local asin = math.asin(vertVector.Y)
	local verticalAngle = math.deg(asin)
	return verticalAngle
end

local function weldBall()
	if weldLock then return end
	local distance = (ball.Position - rootPart.Position).Magnitude
	if distance <= weldDistance and not ball:FindFirstChild("BallMotor") then
		remoteWeldBall:FireServer()
	end
end

UserInputService.InputBegan:Connect(function(Input, GPE)
	if GPE and not inputting then return end
	if Input.UserInputType == Enum.UserInputType.MouseButton1 then
		if debounce or isKicking then return end
		
		debounce = true
		clickedMouseB1 = true
		isKicking = true
		kickBar.Visible = true
		bar.Visible = true
		animation:Play()
		originalWalkSpeed = humanoid.WalkSpeed
		humanoid.WalkSpeed = kickSlowSpeed
		task.delay(0.25, function()
			if isKicking and animation.IsPlaying then
				animation:AdjustSpeed(0)
				animFrozen = true
			end
		end)
		tweenFOV(kickFOV)
		task.delay(0.2, function()
			debounce = false
		end)
	end
end)

UserInputService.InputEnded:Connect(function(Input, GPE)
	if GPE and not inputting then return end
	if Input.UserInputType == Enum.UserInputType.MouseButton1 then
		tweenFOV(defaultFOV)
		local distance = (ball.Position - rootPart.Position).Magnitude
		kickBar.Visible = false
		bar.Visible = false
		if distance <= kickDistance and clickedMouseB1 == true then
			local rootLook = camera.CFrame.LookVector
			local angle = getLookUpAngle()
			local upForce = 0
			if angle > 80 then
				upForce = 1
				rootLook = Vector3.new(0,0,0)
			elseif angle > 10 then
				upForce = angle / 80
			end
			local curveInput = 0
			if UserInputService:IsKeyDown(Enum.KeyCode.A) then
				curveInput = -1
			elseif UserInputService:IsKeyDown(Enum.KeyCode.D) then
				curveInput = 1
			end
			remoteKick:FireServer(rootLook, kickValue, upForce, curveInput)
			weldLock = true
			task.delay(0.4, function()
				weldLock = false
			end)
		end
		if animFrozen then
			animation:AdjustSpeed(1)
			animFrozen = false
		end
		clickedMouseB1 = false
		isKicking = false
		humanoid.WalkSpeed = originalWalkSpeed
	end
end)

local function updateBar()
	
	local barRatio = kickValue / finalYScale
	
	resizeCustomLoadingBar(barRatio, bar, top)
	
end

RunService.Heartbeat:Connect(function(dt)
	if isKicking then
		kickValue = math.clamp(kickValue + kickIncreaseRate * dt, 0, 1)
	else
		kickValue = math.clamp(kickValue - kickIncreaseRate * 5 * dt, 0, 1)
	end

	if animation.IsPlaying and animFrozen and ball:FindFirstChild("BallMotor") then
		local weld = ball:FindFirstChild("BallMotor")
	end

	updateBar()
	weldBall()
end)

character.AncestryChanged:Connect(function()
	if not character:IsDescendantOf(workspace) then
		humanoid.WalkSpeed = originalWalkSpeed
	end
end)
humanoid.Died:Connect(function()
	humanoid.WalkSpeed = originalWalkSpeed
end)