I need help with my script. Why doesnt the animation work with the script?
Script:
local UserInputService = game:GetService("UserInputService")
local plr
local character
local humanoid
local canDoubleJump = false
local amountOfJumps = 0
local oldPower
local TIME_BETWEEN_JUMPS = .2
local DOUBLE_JUMP_POWER_MULTIPLIER = 2
local d = false
local main = script.Parent.Parent.Parent:WaitForChild("main")
local jumpUI = main.DoubleJumpText
local jumpAnim = script:WaitForChild("Animation")
local AnimL
local getMaxDoubleJumps = function()
-- Will Get Later With Val
return 10
end
local setDoubleJumpUI = function()
local maxJumps = getMaxDoubleJumps()
jumpUI.Text = "Double Jumps: "..tostring(amountOfJumps).."/"..tostring(maxJumps)
jumpUI.Visible = true
if amountOfJumps >= maxJumps then
jumpUI.TextColor3 = Color3.fromRGB(191, 21, 6)
jumpUI.TextTransparency = .4
end
end
function onJumpRequest()
if not character or not humanoid or not character:IsDescendantOf(workspace) or
humanoid:GetState() == Enum.HumanoidStateType.Dead then
return
end
if d == false then
local maxJumps = getMaxDoubleJumps()
if canDoubleJump and amountOfJumps < maxJumps then
d = true
humanoid.JumpPower = oldPower * DOUBLE_JUMP_POWER_MULTIPLIER
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
amountOfJumps = amountOfJumps + 1
--AnimL:Play()
setDoubleJumpUI() wait()
d = false
end
end
end
local function characterAdded(newCharacter)
character = newCharacter
humanoid = newCharacter:WaitForChild("Humanoid")
canDoubleJump = false
oldPower = humanoid.JumpPower
AnimL = humanoid:LoadAnimation(jumpAnim)
AnimL:Play()
humanoid.StateChanged:Connect(function(old, new)
if new == Enum.HumanoidStateType.Landed or new == Enum.HumanoidStateType.PlatformStanding then
if canDoubleJump then
canDoubleJump = false
humanoid.JumpPower = oldPower
amountOfJumps = 0
jumpUI.Visible = false
jumpUI.TextColor3 = Color3.fromRGB(255, 255, 255)
jumpUI.TextTransparency = 0
end
elseif new == Enum.HumanoidStateType.Freefall then
wait(TIME_BETWEEN_JUMPS)
canDoubleJump = true
end
end)
end
function module:Int(localPlayer)
if localPlayer.Character then
characterAdded(localPlayer.Character)
end
localPlayer.CharacterAdded:Connect(characterAdded)
UserInputService.JumpRequest:Connect(onJumpRequest)
end
return module```