Hello! I made double jump in my game and made animation, also the game and animation is R15.
I added this script with animation inside parented to it!
The animation only play on the first jump but not for the rest!
local parachutePeople = require(game:GetService(“ReplicatedStorage”).Modules.Extra:WaitForChild(“ParachuteUsers”))
local module = {}
local UserInputService = game:GetService(“UserInputService”)
local plr
local character
local humanoid
local canDoubleJump = false
local amountOfJumps = 0
local oldPower
local TIME_BETWEEN_JUMPS = .325
local DOUBLE_JUMP_POWER_MULTIPLIER = 1.75
local d = false
local running = Enum.HumanoidStateType.Running
local landed = Enum.HumanoidStateType.Landed
local standing = Enum.HumanoidStateType.PlatformStanding
local main = script.Parent.Parent.Parent:WaitForChild(“main”)
local jumpUI = main.DoubleJumpText
local jumpAnim = script:WaitForChild(“Animation”)
local AnimL
local playersWhoHaveParachute = parachutePeople.Users
local bestJumpList = {
[1] = “Jump2”,[2] = “Jump3”,[3] = “Jump4”,[4] = “Jump5”,[5] = “Jump6”,
[6] = “Jump7”,[7] = “Jump8”,[8] = “Jump9”,[9] = “Jump10”,
}
local maxJumpAmount = nil
local setMaxDoubleJumps = function()
local jumpChoosen = nil
for i = #bestJumpList, 1, -1 do
local jumpName = bestJumpList[i]
if jumpName ~= nil then
local val = plr:WaitForChild(“Skills”):FindFirstChild(tostring(jumpName))
if val ~= nil then
jumpChoosen = i break
end
end
end
if jumpChoosen ~= nil then
maxJumpAmount = (tonumber(jumpChoosen)+1)
else
maxJumpAmount = 1
end
end
local getMaxDoubleJumps = function()
if maxJumpAmount ~= nil then
return tonumber(maxJumpAmount)
end
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 == true and amountOfJumps < maxJumps then
d = true
humanoid.JumpPower = oldPower * DOUBLE_JUMP_POWER_MULTIPLIER
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
amountOfJumps = amountOfJumps + 1
AnimL:Play()
canDoubleJump = false
setDoubleJumpUI() wait()
d = false
end
end
end
local function characterAdded(newCharacter)
if playersWhoHaveParachute[plr.Name] == true then
else
character = newCharacter
humanoid = newCharacter:WaitForChild(“Humanoid”)
canDoubleJump = false
oldPower = humanoid.JumpPower
AnimL = humanoid:LoadAnimation(jumpAnim)
setMaxDoubleJumps()
humanoid.StateChanged:Connect(function(old, new)
if new == landed or new == standing or new == running then
if canDoubleJump == true then
canDoubleJump = false
jumpUI.Visible = false
jumpUI.TextColor3 = Color3.fromRGB(255, 255, 255)
jumpUI.TextTransparency = 0
humanoid.JumpPower = oldPower
amountOfJumps = 0
end
elseif new == Enum.HumanoidStateType.Freefall then
if amountOfJumps <= 0 then
wait(.2)
canDoubleJump = true
else
wait(TIME_BETWEEN_JUMPS)
canDoubleJump = true
end
end
end)
end
end
function module:Int(localPlayer)
plr = localPlayer
if plr.Character then
characterAdded(plr.Character)
end
plr.CharacterAdded:Connect(characterAdded)
plr:WaitForChild("Skills").ChildAdded:Connect(setMaxDoubleJumps)
plr:WaitForChild("Skills").ChildRemoved:Connect(setMaxDoubleJumps)
UserInputService.JumpRequest:Connect(onJumpRequest)
end
return module