Assigning UIButton to InputBinding (using the new Input Action System) doesn't work

I’m trying to add mobile controls to my game which uses IAS for all inputs.

The InputBinding in question and my overall setup:


The UI button in question:

Parent ScreenGUI has the highest DisplayOrder among all.

The code, works on PC emulation (normal) but not on mobile device emulation:

self.activeInputs["Fire"] = self.input.Weapon.Fire.Pressed:Connect(function()
	print("fire")
	...
end)

Does anyone have a clue about what I did wrong? “Active” property on the button isn’t the culprit. Yes, I tested it on my phone and no luck either. Thanks all.

1 Like

Firstly, please don’t use OOP because it’s one of the reasons why you misunderstood why this is happening
You see, everything under StarterGui is not the same as what the player does see
StarterGui merely gets cloned to PlayerGui (one of the reasons why you must either manually parent it to PlayerGui from client or just write it from code, e.g. HierarchySaver)
Essentially, your input action is bound to the StarterGui instance when it should’ve been bound to the PlayerGui one

Quick solution would be putting all your StarterGui GUI somewhere in replicated storage folder and then :GetChildren() parent all of them to PlayerGui using local script

Israel forced me to use OOP, if I don’t they’ll kill my family. Sorry.

I tried re-assigning the UIButton property while the game was running (when it is in PlayerGui), and it works! I was aware that StarterGui is just getting copied to PlayerGui but I didn’t think of it in this context, thanks for the great observation.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.