Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

CAS overrides UIS's gameProcessedEvent parameter rendering it useless? [answered]

UserInputService.InputBegan:Connect(function(InputObj, gameProcessedEvent) if gameProcessedEvent then return; end; end);

When a player is typing in the chat or in a text box gameProcessedEvent will be set to true letting you not do something you'd normally do for user input events,

however, using ContextActionService:BindAction(name, func, mobile_button_bool, input_types_tuple) will set gameProcessedEvent to true as if you were chatting making using it practically in games for sprinting or using an item isn't possible as it'd stop other important systems you have in place such as movement in UserInputService.

Wondering if there's a system that can be put in place with little overhead that will allow you to use both ContextActionService and UserInputService simultaneously together with ease,

such as

local uis_b, uis_e = Enum.UserInputState.Begin, Enum.UserInputState.End;

ContextActionService:BindAction("example", function(InputObj)
	local uis = InputObj.InputState;
	if uis == uis_b then
		_G.gameProcessedEventOverride = true;
	elseif uis == uis_e then
		_G.gameProcessedEventOverride = false;
	end;
end, false, Enum.KeyCode.LeftShift);

UserInputService.InputBegan:Connect(function(InputObj, gameProcessedEvent)
	if gameProcessedEvent and not _G.gameProcessedEventOverride then return; end;
	--docode
end);

Would this really be the best way to do things?

7 comments

0

Also I assume having many UserInputService.InputBegans for different scripts would be highly inefficient rather than using ContextActionService for specific hotkeys yes?

0

Also for clarification ContextActionService automatically doesn't fire when a player is typing lol :P

0

It's CAS:BindAction() and I don't see why both services are needed at a time.

0

ContextActionSevice is supirior to UserInputService, as it function siamotainously for Keyboard and Mobile input

0

Both have different use cases.

0

Sorry xPol my mistake, and they're used for different things, UserInputService is generally used when you need to have an event for all inputs collectively (where you can then use a table and indexes to select specific ones like CAS), and CAS is C sided and only handles the keycodes you pass through

0

I'd rather not bloat my code with InputBegans for very different things when I could just use CAS as it was intended to be used for however if you use UIS regardless using CAS isn't really an option unless you put a system in place for gameProcessedEvent ;/

1 answer

It appears UserInputService has 2 events,

TextBoxFocused(TextBox) and TextBoxFocusReleased(TextBox)

I'm just going to use these two and then set _G.isTyping = true/false, this is a better system then gameProcessedEvent anyhow as gameProcessedEvent has many bugs elsewhere too,

Thanks ^-^

This discussion is preserved as it was. New answers, comments, and votes are closed.