You have an else statement, basically saying if it wasn’t the tab key being clicked, it will go to the else statement.
local user_input_service = game:GetService('UserInputService')
user_input_service.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.Tab then
-- When tab is pressed
print("A")
else
-- When any other key is pressed (including mouse)
print("B")
end
end)
Try removing the else, that should work.
If you are trying to check if the cellphones position changed, use elseif instead.
local user_input_service = game:GetService('UserInputService')
user_input_service.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.Tab then
-- When tab is pressed
print("A")
elseif true == true then -- Check if the cellphones position is different
-- When any other key is pressed (including mouse)
print("B")
end
end)
Your script should look like this if you are using the elseif statement.
local user_input_service = game:GetService('UserInputService')
local cellphone = script.Parent:WaitForChild('cellphone')
user_input_service.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.Tab and cellphone.Position == UDim2.new(0.189, 0,1.202, 0) then
cellphone.Position = UDim2.new(0.189, 0,0.74, 0)
elseif cellphone.Position == UDim2.new(0.189, 0,1.202, 0) then
cellphone.Position = UDim2.new(0.189, 0,1.202, 0)
end
end)