Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

[ANSWERED] How do I modify this script to double jump with "W" instead of "Space"?

I want to make a 2D action platformer game that is very similar to Super Smash Bros. It is supposed to make it so if I press "W" in midair if the player didn't double jump yet. However, I found this script for double jumping (I suck at scripting) but it only double jumps when I press space. What do I have to modify?

db=false
j=0
local plyr = game.Players.LocalPlayer
repeat wait() until plyr.Character
plyr.Character.Humanoid.WalkSpeed=24
local InputKey = "Space"
deb=false
J1=false
J2=false
local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:connect(function(UserInput)
	if UserInput.UserInputType == Enum.UserInputType.Keyboard  then

        	if UserInput.KeyCode == Enum.KeyCode[InputKey] and J1==true and deb==false and j==1 and plyr.Character.UpperTorso.Velocity.Y~=0 and db==false then
	j=2
	deb=true
	plyr.Character.UpperTorso.Velocity=Vector3.new(0,50,0)
	
	pe=script.ParticleEmitter:Clone()
	pe.Parent=plyr.Character.UpperTorso

	script.Sound:Play()
		wait(.3)
	pe:Destroy()
	J2=true

	
	deb=false

		end
	end
end)

function D()
	if  J1==false then
		db=true
		J1=true
		script.S2:Play()
		j=1
		db=false
	end
end
plyr.Character.Humanoid.Jumping:connect(D)

while wait() do
	if plyr.Character.UpperTorso.Velocity.Y>-.1 and plyr.Character.UpperTorso.Velocity.Y<.1 then
		J1=false
		j=0
	
	end
end

Any help is appreciated!

4 comments

1

line 6, did you try changing that to W?

1

Try changing your InputKey variable to "W", or make your own script.

0

Wow thanks let me try it

0

I'm an idiot xD

1 answer

✓ Accepted answer

Just to officially mark this as answered, multiple people suggest see that the variable on line 6 be changed to "W", which ended up working.

2 comments

0

Thanks man! I am just the biggest idiot or am the most blind person in the world.

0

Neither, even the pros do the same thing xD

This discussion is preserved as it was. New answers, comments, and votes are closed.