I’ve been making a double jump system and it has this cooldown, and while its in cooldown, the double jump “recharges” but the thing is, the UI wont show up. Here is the code:
local PL = game:GetService("Players")
local UIS = game:GetService("UserInputService")
local TS = game:GetService("TweenService")
local STGUI = game:GetService("StarterGui")
local DoubleJumpChargeUI = STGUI:WaitForChild("DOUBLEJUMPCHARGE")
local canvasGroup = DoubleJumpChargeUI:FindFirstChild("CanvasGroup")
local BackgroundUI = canvasGroup:FindFirstChild("Background")
local BarUI = BackgroundUI:FindFirstChild("Bar")
local TextUI = canvasGroup:FindFirstChild("TextStats")
local player = PL.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local cooldown = 3
local lastJumpTime = 0
local hasDoubleJumped = false
local previousJump = tick()
local doubleJumpInfo = TweenInfo.new(
cooldown,
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0,
false,
0
)
local doubleJumpUIInfo = TweenInfo.new(
0.25,
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0,
false,
0
)
local doublejumpgoals = {
Size = UDim2.new(1, 0, 1, 0)
}
local outUIdoublejumpgoals = {
GroupTransparency = 1
}
local InUIdoublejumpgoals = {
GroupTransparency = 0
}
local doubleJumpAnim = TS:Create(BarUI, doubleJumpInfo, doublejumpgoals)
local outUIDoubleJumpAnim = TS:Create(canvasGroup, doubleJumpUIInfo, outUIdoublejumpgoals)
local inUIDoubleJumpAnim = TS:Create(canvasGroup, doubleJumpUIInfo, InUIdoublejumpgoals)
local function doubleJump()
if tick() - previousJump >= 0.2 then
if humanoid:GetState() == Enum.HumanoidStateType.Freefall and not hasDoubleJumped then
local currentTime = tick()
if currentTime - lastJumpTime >= cooldown then
lastJumpTime = currentTime
hasDoubleJumped = true
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
doubleJumpAnim:Play()
inUIDoubleJumpAnim:Play()
task.wait(cooldown)
BarUI.Size = UDim2.new(1, 0, 1, 0)
outUIDoubleJumpAnim:Play()
end
end
end
end
humanoid.StateChanged:Connect(function(old, new)
if new == Enum.HumanoidStateType.Landed then
hasDoubleJumped = false
elseif new == Enum.HumanoidStateType.Jumping then
previousJump = tick()
end
end)
UIS.JumpRequest:Connect(doubleJump)```