In my game, I made a menu (Screen Gui), there are buttons in it. When I click those buttons on pc, they work perfectly well. But when I play on a mobile device (Ipad, Phone), and i try to click the buttons, they do not work (nothing happens when i press them).
There isn’t any errors in the script thats in the button, so i don’t know what the problem is, if you could help, i appreciate it.
If you need more info, leave a reply and ill provide it for you.
We need to be able to see your code to understand where we need to help you. For example, are you using the MouseButton1Click, TouchTap, Activated events? Please always include any associated code in the initial post.
That is most likely the reason why. On mobile, there is no mouse input, therefore MouseButton1Click in unusable. For mobile users, the equivalent would be the TouchTap event.
Put this script in the ServerScriptService
--Services
local players = game:GetService("Players")
local gyroService = game:GetService("UserInputService")
local function onJoin(plr)
plr.CharacterAdded:Connect(function()
local onMobile = Instance.new("BoolValue", plr.Character)
onMobile.Name = "onMobile"
if gyroService.GyroscopeEnabled then
onMobile = true
else
onMobile = false
end
end)
end
players.PlayerAdded:Connect(onJoin)
Your original posted script, but updated:
local player = game.Players.LocalPlayer
local button = script.Parent
local ScrollingFrame = script.Parent.Parent.Parent.TeamChooseFrame
local MainMenu = script.Parent.Parent.Parent.MainMenu
local Frame = script.Parent.Parent.Parent.MainMenu.Offset.Frame
local onMobile
player.CharacterAdded:Connect(function()
if player.Character.onMobile then
onMobile = true
else
onMobile = false
end
if onMobile then
button.TouchTap:Connect(function()
ScrollingFrame:TweenPosition(UDim2.new(0.5, -250,1.16, -200), Enum.EasingDirection.In, Enum.EasingStyle.Quad)
wait(0.9)
ScrollingFrame.Visible = false
MainMenu.Visible = true
Frame:TweenPosition(UDim2.new(0, 0,0, 0), Enum.EasingDirection.In, Enum.EasingStyle.Quad)
end)
else
button.MouseButton1Click:Connect(function()
ScrollingFrame:TweenPosition(UDim2.new(0.5, -250,1.16, -200), Enum.EasingDirection.In, Enum.EasingStyle.Quad)
wait(0.9)
ScrollingFrame.Visible = false
MainMenu.Visible = true
Frame:TweenPosition(UDim2.new(0, 0,0, 0), Enum.EasingDirection.In, Enum.EasingStyle.Quad)
end)
end
end)