It’s too kinda picky, the thing is you only wrote the disabled part after the player landed so they can still infinite jump but if they hit a part that leads to the humanoid state switching to landed state, they would be not be able to temporarily double jump for 0.5 seconds, then they would be able to infinite jump again.
oh i was wrong oof, but i really want to try it
If you’re having too much trouble trying to replicate what i explained, i might as well create a place that you could download later and copy the script.
Everything that I tried didn’t work
Did you know that “W” is known to move your character forwards so thats why when you are moving your character it will always jump. You should use Enum.KeyCode.Space
, you can research all the possible keycodes you can use here.
Here’s a code i tried, it worked so your problem is probably gone now.
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = char:WaitForChild("HumanoidRootPart")
local humanoid = char:WaitForChild("Humanoid")
local jumpUsage = 1
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(key, gp)
if key.KeyCode == Enum.KeyCode.Space and not gp then
if humanoidRootPart and humanoid then
if humanoid:GetState() == Enum.HumanoidStateType.Freefall then
if jumpUsage >= 1 then
jumpUsage -= 1
humanoid:ChangeState(Enum.HumanoidStateType.Jumping, true)
humanoid.StateChanged:Connect(function(old, new)
if new == Enum.HumanoidStateType.Landed then
jumpUsage = 1
end
end)
end
end
end
end
end)
Make sure it’s in starterpack, startergui or anywhere suitable and don’t forget it must be a local script!
-- i wont be adding variables like character, player, or humanoid, those can be taken
-- care easily
-----
--shorten the state types
local jumping = Enum.HumanoidStateType.Jumping;
local falling = Enum.HumanoidStateType.Freefall;
local landed = Enum.HumanoidStateType.Landed;
local doubleJump = false;
humanoid.StateChanged:Connect(function(old, new)
if (old == falling) and (new == landed) then
doubleJump = false;
return;
end
if (old == jumping) and (new == falling) then
doubleJump = true;
coroutine.wrap(function() --optional
wait(.8);
doubleJump = false;
end)()
end
end)
uis.InputBegan:Connect(function(inp, gpe)
if gpe then
return;
end
if inp.KeyCode == Enum.KeyCode.Space then
if (doubleJump) then
doubleJump = false;
humanoid:ChangeState(jumping);
end
end
end)
Try this one.
Can you define what does “gp” mean?
It either means game procession or process, we need that so the script doesn’t fire while your typing.
gpe stands for “game-processed event”. In order to simplify it, when someone is typing through a textbox GUI or is typing in chat, then that’s gpe. If we don’t want the entire contents of the inputbegan event to function if the player is typing through a textbox or is typing in a chat, we use an if statement to see if it’s a game-processed event.
It shows an error on “gp” is it supposed to be a variable?
gpe, not gp. You did it wrong. (ignore this, thought you were talking about my script)
If his doesn’t work, try mine. gp is supposed to be a parameter returned by inputbegan
The second argument on the inputbegan function is the game processed event, the first one is the key you pressed, it’s not supposed to be a variable though, or is it?
Edit: btw what’s taking you so long, nomcell to even copy these and say if it’s working or nat
There is not really a need for any ints or arithmetic subtractions for debounces here. We are talking about double jumps.
shows this
What does that mean? I haven’t saw that kind of error output type.
It’s roblox’s syntax highlighting breaking again, it’s not an error, just try the script.
Also can you show us the script you used? I don’t know if your using mine or that modeler guy.
I am not really the type of person to say this, but your code is not really done well, and I doubt it would function properly as it should. Why is the StateChanged
event inside another event that is not related to it? Why are you using Int64’s for a debounce?
whats an in64 xxlamlnevitables