What is this line doing

I don’t remember where I got this script from, but I think I should remove line 5, right? And if that’s not the case, what exactly does it do?

----------------Left--------------

uis.InputBegan:Connect(function(inputObject, gameProcessedEvent, gameProcessed)

if gameProcessed then return end -- << This line

	if (inputObject.KeyCode == KeyLeft[1]) or (inputObject.KeyCode == KeyLeft[2]) then
		LeftKey.Looped = true
		StopAllAniamtions()
		LeftKey:Play()
	end
end)

uis.InputEnded:Connect(function(inputObject, gameProcessedEvent, gameProcessed)
	if gameProcessed then return end -- << this is the same

	if (inputObject.KeyCode == KeyLeft[1]) or (inputObject.KeyCode == KeyLeft[2]) then
		LeftKey.Looped = false
	end
end)

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

Each connection to an input function will return its own gameProcessed parameter, so it’s wise to leave it to allow separate functionalities to return themselves should their action be observed by the engine internally.

1 Like

That line checks if the key pressed was meant for something else like chatting.

For example, if you have a key that plays a punch animation when F is pressed, you don’t want that animation playing whenever the player presses F when typing in chat. That’s basically what gameProcessed does.

You should leave that in there.

3 Likes

I already understood, thank you very much

ok thank you very much i didn’t know that too