Hello!
I’m working on a smash bros game and I already have most of the things setup already for the game
One of the things I haven’t setup yet is a double jump, which I started doing a few days ago
The problem is that, the script I have for my double jump doesn’t work with my custom character selection.
I have a GUI to select characters, and basically all it does it when a player picks a character, it copies the character from ReplicatedStorage and sets that as the player’s character, then it copies all the scripts which are also in ReplicatedStorage and puts them in the character.
The script works if I place it within the starter character, but not if it’s in the custom character. I also messed around with the print function in my script and found out that the problem is that the script doesn’t detect when a player requests to jump, or when the humanoid state is changed
Can anyone help me figure out whats wrong? Also sorry for the lenghty post, this is my first post and I wanted to make sure it covered everything !
local UserInputService = game:GetService("UserInputService")
local player = game:GetService("Players").LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
if character.Name == "Builderman" then
print("A")
end
local MAX_JUMPS = 2
local TIME_BETWEEN_JUMPS = 0.2
local numJumps = 0
local canJumpAgain = false
humanoid.StateChanged:Connect(function(oldState, newState)
if Enum.HumanoidStateType.Landed == newState then
numJumps = 0
canJumpAgain = false
elseif Enum.HumanoidStateType.Freefall == newState then
wait(TIME_BETWEEN_JUMPS)
canJumpAgain = true
elseif Enum.HumanoidStateType.Jumping == newState then
canJumpAgain = false
numJumps += 1
end
end)
game:GetService("UserInputService").JumpRequest:Connect(function()
if canJumpAgain and numJumps < MAX_JUMPS then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
end)