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.