UIS working for shift keycode only

I was trying to make a advanced stamina gui. but I stumbled into a problem that was weird

If I were to press Q, it should print out “hi”, but it didn’t work.
But if I changed the Keycode to LeftShift, it would work and print out “hi”

local uis = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local gui = plr.PlayerGui:WaitForChild("Stamina")
local character = plr.Character
local tool = plr.Backpack.Sword

local dashPower
local power
local debounce = false
local canslide = true
local keybind = Enum.KeyCode.Q

uis.InputBegan:Connect(function(input,gameprocessed)
	if gameprocessed then return end
	if tool:IsDescendantOf(character) and canslide == true then
		canslide = false
		if input.KeyCode == keybind then
			print("Hi")
		end
		canslide = true
	end
end)

does anyone know a fix for this?

1 Like

Hello,
I just tested your script in a new baseplate and it worked perfectly fine.
Is there any more context you can add to your situation which could help us help you fix your problem?

It is in startergui if that helps, but it doesnt work for me when I change it to Q

Do you have the latest studio version?
When you test it are you sure you are equipping the sword?

Yeah I did everything. I think this might be important, the script is inside a frame

I just tested by putting print(“hi”) inside the dash ability that works, and it didnt print but it works

I’m sorry, I have no idea what the issue might be.
Your script is solid from what I can tell, there’s no real reason why it would work with one keybind and not the other.

I again apologize and hope someone else might be able to assist you.

1 Like