Keyboard ability

I want an keyboard button or Controller, Have ability to hit signal 'TextButton Self trigger from it.

------------------------------

------------------------------

It doesn’t self trigger when i click, any button like R(KeyCode) to hit RC ‘TextButton’ < self trigger from the Keycode i press, connection. It you don’t understand, response here.

Kind regard, Joshua7ninjaX

You can’t fire the MouseButton1Click event, instead create a function then connect it to the event and in the UIS onKeyPress just call the function after you’ve checked the keycode

So is impossible without Mouse1buttonclick, when i click Keyboard button, i see TextButton properties like it said, Active and Selected. Is there any way?

No, send me the script and I can try to modify it for you.

function onKeyPress(inputObject)
if inputObject.KeyCode == Enum.KeyCode.R then
script.Parent.RC.MouseButton1Click:Connect(function() – RC is a button

game:GetService(“UserInputService”).InputBegan:connect(onKeyPress)

end

I might have to send you a model, for you to modify

1 Like

what you need to use is the context action service like this

local contextActionService = game:GetService("ContextActionService")
local KEY = "Key"
local button -- put the ui button here
local function OnBinded(actionName,inputstate,inputObj)
      if actionName == KEY then
            --put here what you want to happen
      end
end
contextActionService:BindAction(KEY,OnBinded,false,Enum.KeyCode.R)
button.MouseButton1Click:Connect(OnBinded)

you can read more about it here ContextActionService | Documentation - Roblox Creator Hub

1 Like
local function Clicked() -- make func
	print("stuff you want to do")
end

script.Parent.RC.MouseButton1Click:Connect(Clicked) -- connect it to clicked

game:GetService("UserInputService").InputBegan:Connect(function(input, gpe) -- connect a func to input began
	if gpe then return end -- check if user is chatting
	if input.KeyCode == Enum.KeyCode.R then -- check if its r
		Clicked() -- call func
	end
end)

tbh CAS is kind of weird, isn’t it for holding down keys and not pressing them for toggle? When i was trying to use it for a menu it opened when i pressed q but closed when i let go

What will ‘RC’ button do is this, this is different script, but you know sometime when you use xbox and toggle gui it get clumsy, so it’s alot easier for users to press keycode like example Dpad right or left, Gui page flipping and then you don’t have to navigate.

Sorry for delay, i kept getting this
17:49:52.520 - BinAction is not a valid member of ContextActionService

@RomeoEDD

BindAction!

A minor typo, but in scripting it is very important.

Anyway, you should have a function to handle when it’s clicked and then call that function based on the other inputs.

oh yeah i fixed it thank you for pointing it out

No offense, if you do like to try go ahead and find the solution.

I tested out my script, both the button and the R key printed out “stuff you want to do”

local function Clicked() -- make func
	print("stuff you want to do")
end

script.Parent.RC.MouseButton1Click:Connect(Clicked) -- connect it to clicked

game:GetService("UserInputService").InputBegan:Connect(function(input, gpe) -- connect a func to input began
	if gpe then return end -- check if user is chatting
	if input.KeyCode == Enum.KeyCode.R then -- check if its r
		Clicked() -- call func
	end
end)

It did print out when i press R, I copy and paste on the script ‘stuff you want to do’ Note: Model i posted link is on the post for you to check out.

local function Clicked() – make func
print(“stuff you want to do”)

	CurrentPage = 1 --the current page

function FlipPage(Way)
local NewPage = CurrentPage+Way – calculate which page should be the current page
if script.Parent.BFrame.MSFrame:findFirstChild(“Q”…NewPage)~=nil then – see if the new page exists
CurrentPage = NewPage
local P = script.Parent.BFrame.MSFrame:GetChildren()
for i = 1, #P do
P[i].Visible = false – first make every page transparent
end
script.Parent.BFrame.MSFrame:findFirstChild(“Q”…NewPage).Visible = true – show the right page
end
end

script.Parent.RC.MouseButton1Down:connect(function() FlipPage(1) end) – flip to the right
script.Parent.LC.MouseButton1Down:connect(function() FlipPage(-1) end) – flip to the left
end

script.Parent.RC.MouseButton1Click:Connect(Clicked) – connect it to clicked

game:GetService(“UserInputService”).InputBegan:Connect(function(input, gpe) – connect a func to input began
if gpe then return end – check if user is chatting
if input.KeyCode == Enum.KeyCode.R then – check if its r
Clicked() – call func
end
end)

@azahid1

Give me a few minutes to make something

Here, a fixed copy of the model:

I recorded a video of it: (quality might be bad for a few minutes so wait for youtube)

1 Like

@azahid1

Big thank to you.

About the left button, i was gonna do that further after the solve, then again THANK YOU!
Why do i want that, because it is for Xbox user i can eventually update whether button like DPad left or right

1 Like

You should also put the MouseButton1Click event in the KeyDown script, it’s just good practice.