I have been performing tests this week on the mobile gameplay of one of my games and I’ve finally found the reason why the character would never set up as it should (and as it does on computer).
I have this line of code to retrieve the HumanoidController from the ControllerService (the object that you can re-parent to enable/disable character control):
print("PlayerScript loading...")
print("0")
local ControlService
repeat ControlService = game:GetService("ControllerService") wait() until ControlService ~= nil
print("1")
I’ve been using this in all of my games as I’ve convinced myself that the ControllerService does not happen immediately when the player has been connected. I usually wait about a second, although some peoples’ connections may extend the wait.
To emphasize: These lines work in every game I’ve made that I’ve need them for. Only on PC clients, unfortunately.
Is this correct behavior on the part of the mobile client?
[size=2]Note: “Unblacking out” is from the GUI-handling script. Please omit.[/size]
[size=2]Note: “Unblacking out” is from the GUI-handling script. Please omit. The numbers are prints() I put throughout the localscript that would indicate when it stopped working (between 0-1, where the ControllerService is being fetched), and “PlayerScript running” is at the end of the script once everything has successfully loaded.[/size]