I can't get the keycode to work that is used depending on the player's power

Hi, I have a little problem with a part of the UserInputService. For some reason when I press the keycode F to use the ability, nothing happens and no errors in the dev console. The power I have equipped is Radar and for some reason the ability doesn’t work. If anyone knows how to fix this little mistake, I would appreciate it very much.

(Edit): The abilities work when I use the MouseButton1Click, but what doesn’t work is the Keycode, that’s all.

image

2 Likes

You have the end for your debounces in the wrong place.

if input.KeyCode==Enum.KeyCode.F then
    if not debounce then
       -- code
    end
elseif input.KeyCode == -- rest of code
1 Like

Have you tried print debugging? Also make sure you place your debounce statements correctly or else it wouldn’t fire the second time you press F.

1 Like

I am trying to make all the abilities be used by the same Keycode, I tried your script but I get something like this.

image

1 Like

you just need one end after the debounce, adding a second one breaks the elseif:

if input.KeyCode==Enum.KeyCode.F then
    if not debounce then
       -- code
    end  --- End for the debounce
elseif input.KeyCode == -- rest of code 
   if not debounce then
    -- code
  end
elseif input.KeyCode== --
   if not debounce then
   -- code
   end
end -- end of elseif's
2 Likes
if input.KeyCode==Enum.KeyCode.F then
	if player.EquippedVictimPower.Value=="Sprint" then
		if not debounce then
			debounce=true
			sprint()
			wait(1)
			debounce=false
		end
	elseif player.EquippedVictimPower.Value=="Radar" then
		if not debounce then
			debounce=true
			radar()
			wait(1)
			debounce=false
		end
	elseif player.EquippedVictimPower.Value=="Nightvision" then
		if not debounce then
			debounce=true
			nightvision()
			wait(1)
			debounce=false
		end
	end
end
1 Like

Try this instead.

if input.KeyCode == Enum.KeyCode.F then
	if player.EquippedVictimPower.Value == "Sprint" then
		if not debounce then
			debounce=true
			sprint()
			wait(1)
			debounce=false
		end
	elseif player.EquippedVictimPower.Value == "Radar" then
		if not debounce then
			debounce=true
			radar()
			wait(1)
			debounce=false
		end
	elseif player.EquippedVictimPower.Value == "Nightvision" then
		if not debounce then
			debounce=true
			nightvision()
			wait(1)
			debounce=false
		end
	end
end
1 Like

Thank you very much, you helped a lot me on this one

2 Likes

Sorry I didn’t read this one but glad that you tried to help too.

2 Likes