I have a LocalScript inside the player(s), which records if a player presses Spacebar while in the air, it initiates the function Geppo which makes it look like a double jump. I have 2 animations for Geppo: GeppoLeft, which is the player moving his left leg, and GeppoRight, which is the player moving his right left.

I want it so when they player double jumps, it does GeppoLeft, then does GeppoRight the next time they use Geppo, but I don't really know of a way to do this with how I have my code setup. If anyone could help, it would be much appreciated.

Code:

--//Services
local UserInputService = game:GetService('UserInputService')
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Players = game:GetService('Players')

--//Variables
local Player = game.Players.LocalPlayer
Player.CharacterAdded:Wait()
local Character = Player.Character
local Humanoid = Character:WaitForChild('Humanoid')	
local Root = Character:WaitForChild('HumanoidRootPart')
local RightFoot = Character:WaitForChild('RightFoot')
local LeftFoot = Character:WaitForChild('LeftFoot')
local InAir = false
local KeyHeld = false
local Debounce = false
local GeppoCooldown = 0.5

--//Animations
GeppoAnimTable = {'rbxassetid://2205325471', 'rbxassetid://2205328205'}
local GeppoAnim = Instance.new('Animation')
GeppoAnim.AnimationId = GeppoAnimTable[1]
GeppoAnimTrack = nil

--//Sounds


--//Coding
function Geppo()
	GeppoAnimTrack = Humanoid:LoadAnimation(GeppoAnim)
	GeppoAnimTrack:Play()
	Root.Velocity = Vector3.new(Root.Velocity.X, 100, Root.Velocity.Z)
	print('geppo')
end
function ChooseGeppoAnim()
	if GeppoAnim.AnimationId == GeppoAnimTable[1] then
		GeppoAnim.AnimationId = GeppoAnimTable[2]
	end
	if GeppoAnim.AnimationId == GeppoAnimTable[2] then
		GeppoAnim.AnimationId = GeppoAnimTable[1]
	end
end
Humanoid.StateChanged:Connect(function(Old, New)
	if New == Enum.HumanoidStateType.Freefall or New == Enum.HumanoidStateType.Jumping then
		InAir = true
	else
		InAir = false
	end
end)
function onKeyPress(input, gameEvent)
	if not Debounce and not gameEvent then
		Debounce = true
		if input.KeyCode == Enum.KeyCode.Space and InAir then
			Geppo()
			ChooseGeppoAnim()
			wait(GeppoCooldown)
		end
		Debounce = false
	end
end

UserInputService.InputBegan:Connect(onKeyPress)

4 comments

0

Just so you know ServerScriptService and ServerStorage are inaccessible by clients.

0

Oh yeah, I just have all my scripts setup the same format, I just forgot to remove it.

0

I edited the code above and that somehow didn't work either, if you know of a way to fix.

0

Nevermind, I figured it out!