Buttons not appearing on some mobile devices

I’ve been creating a hockey game over the last week and it’s nearly done.

However, when testing with my friend who plays mobile, has missing buttons. I’ve tried using ContextActionService and TextButtons, but they did not remedy the problem. In both cases, the buttons did not even appear.

Here is the current code using a TextButton in an attempt to make to it work:

StarterGui/GuiObject/LocalScript
local function bindShoot()
	ContextActionService:BindAction("Shoot",Shoot,false, Enum.UserInputType.MouseButton1, Enum.KeyCode.ButtonR2)
	ContextActionService:SetTitle("Shoot","Shoot")
	ContextActionService:SetPosition("Shoot", UDim2.new(1, -160, 0, 40))
end

ReplicatedStorage.Remotes.PuckUpdate.OnClientEvent:Connect(function()
	local oldInput = nil
	local function setupInput()
		local currentPlayerInput, inputEnum = PlayerInputModule.getInputType()
		
		if oldInput ~= currentPlayerInput then
			oldInput = currentPlayerInput
			if currentPlayerInput == "Keyboard/Mouse" or currentPlayerInput == "Gamepad" then
				if mobileBegan then
					mobileBegan:Disconnect()
					mobileEnded:Disconnect()
				end
			
				script.Parent.MobileButton.Visible = false
				bindShoot()
			elseif currentPlayerInput == "Touch" then
				script.Parent.MobileButton.Visible = true
				mobileBegan = script.Parent.MobileButton.InputBegan:Connect(function(input, processed)
					Shoot(nil,input.UserInputState,nil)
				end)
				mobileEnded = script.Parent.MobileButton.InputEnded:Connect(function(input, processed)
					Shoot(nil,input.UserInputState,nil)
				end)
			end
		end
	end
	lastInputConnection = UIS.LastInputTypeChanged:Connect(setupInput)
	setupInput()
end)

And here is the old code:

StarterCharacterScripts/LocalScript
local function bindShoot()
    ContextActionService:BindAction("Shoot",Shoot,true, Enum.UserInputType.MouseButton1, Enum.KeyCode.ButtonR2)
    ContextActionService:SetTitle("Shoot","Shoot")
    ContextActionService:SetPosition("Shoot", UDim2.new(1, -160, 0, 40))
end

ReplicatedStorage.Remotes.PuckUpdate.OnClientEvent:Connect(function()
 bindShoot()
end)

Here is what it looks like on my friend’s screen:


…and here is what it looks like for me:

This is extremely frustrating, and I’m unsure if it’s a bug since both playtesting on my phone and emulating through studio seems to be unable to replicate the issue. It only persists on his end.

Any help would be appreciated.

I’m starting to think it’s a bug on mobile… I’m not 100% sure, and I can’t find any other cases of this.

Try checking if the buttons are out of the screen by setting their position to 0,0,0,0.

I tried your code in studio with ContextActionService and it works fine for me running on emulation as well. When exactly does this ‘PuckUpdate’ client event fire to the client?

Whenever the player comes in contact with the puck. I don’t think it’s the problem because it works fine for me and other friends.

Do these actions ever unbind when you press the shoot button?

I don’t think it’s the problem because it works fine for me and other friends.

Does this happen the first time or is it later on? Is there anyone else that can reproduce this problem? Or is it just him? My idea is that this probably doesn’t get received on the client for that team. You should make a separate place with a test button and see if they still disappear for him.

It happens the first time, he has never seen the shoot button. I haven’t been able to reproduce the problem on an emulator or phone, and none of my other friends encountered the issue.

I’ll try making a test place in a little bit, I’ll let you know when I do.

1 Like

Good news!

I figured out the issue, it was the animations causing the problem. They were erroring and breaking the script, but only for him for some reason. However, that kind of changes what my question is entirely now.

The animations have never seemed to work for my friend, and I decided to look into it at a later time and solve the more pressing bugs within my scripts.

I guess I should consider making a new topic?