So I’m trying to make a piano script, but UIS.InputBegan doesn’t run when I press LeftShift + (2,3,4,5,6,7,8,9,0) but it runs if I press LeftShift + 1
Here’s my script.
UIS.InputBegan:Connect(function(Input,GPE)
print('inputbegan') -- Doesn't print when I press LeftShift + (2,3,4,5,6,7,8,9,0)
if GPE then return end
if Input.KeyCode.Value == 0 then return end
local char
pcall(function()
char = string.char(Input.KeyCode.Value)
end)
if char and table.find(keyMap,char) then
if UIS:IsKeyDown(Enum.KeyCode.LeftShift) or UIS:IsKeyDown(Enum.KeyCode.RightShift) then
char = Module.ShiftChar(char)
end
print(keyMap[table.find(keyMap,char)])
end
end)
Edit : I just remembered, Shift + P is the FreeCam, how can I disable this too?
freecam is in playerscripts or playergui, i forget
does your function run when you just press shift
if this is the case i believe inputbegan only runs when pressing the first key, and wont run if a key is being held down. try researching ways of doing multiple key inputs (the freecam script does that with shift + p)
Sorry that I have to unmark your reply as a solution, but it still doesn’t detect LeftShift + (2,3,4,5,6,7,8,9,0). I tried to find different ways to get the key pressed but couldn’t find any sadly.
Here’s my new script though
function getKeys()
return {
Enum.KeyCode.One;
Enum.KeyCode.Two;
Enum.KeyCode.Three;
Enum.KeyCode.Four;
Enum.KeyCode.Five;
Enum.KeyCode.Six;
Enum.KeyCode.Seven;
Enum.KeyCode.Eight;
Enum.KeyCode.Nine;
Enum.KeyCode.Zero;
Enum.KeyCode.Q;
Enum.KeyCode.W;
Enum.KeyCode.E;
Enum.KeyCode.R;
Enum.KeyCode.T;
Enum.KeyCode.Y;
Enum.KeyCode.U;
Enum.KeyCode.I;
Enum.KeyCode.O;
Enum.KeyCode.P;
Enum.KeyCode.A;
Enum.KeyCode.S;
Enum.KeyCode.D;
Enum.KeyCode.F;
Enum.KeyCode.G;
Enum.KeyCode.H;
Enum.KeyCode.J;
Enum.KeyCode.K;
Enum.KeyCode.L;
Enum.KeyCode.Z;
Enum.KeyCode.X;
Enum.KeyCode.C;
Enum.KeyCode.V;
Enum.KeyCode.B;
Enum.KeyCode.N;
Enum.KeyCode.M;
}
end
function module.getKeyPressed()
local key = ''
for _, keycode in getKeys() do
if UIS:IsKeyDown(keycode) then
key = string.char(keycode.Value)
if UIS:IsKeyDown(Enum.KeyCode.LeftShift) or UIS:IsKeyDown(Enum.KeyCode.RightShift) then
key = module.stringUpper(key)
end
break
end
end
return key
end
Ok, I just got a piano model and I found this function.
function LetterToNote(key, shift, ctrl)
local note = letterNoteMap:find(string.char(key), 1, true)
if note then
return note + Transposition.Value + (shift and 1 or ctrl and -1 or 0)
end
end
I guess this can work.
Edit : Did you mean looking at the piano model script, or did you really mean the FreeCam script?