Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why can I open a menu on PC but not on Mobile?

Asked by
Dalamix 26
4 years ago

I used an Activated event to trigger this function. It works on PC but on mobile the button just goes dark when I click it, but no menu pops up. I know that the If parameter for ContinueScreen doesn't mess with it, I tried removing it and testing on mobile but same result.

Script:

01button.Activated:connect(function()
02    if (not main:FindFirstChild("ContinueScreen")) or (main:FindFirstChild("ContinueScreen") and main.ContinueScreen.Visible == false)   then
03 
04            menu.Position = UDim2.new(0, 0,0.2, 0)
05 
06            Sound.Pitch = 1
07            Sound:Play()
08            if button.Title.Text == "Menu >" then
09                button.Title.Text = "Menu <"
10                button.Title.DropShadow.Text = button.Title.Text
11                char.Humanoid.WalkSpeed = 0
12                menu:TweenPosition(UDim2.new(0, 0,0.2, 0),"Out",'Quad',.25,true)
13            elseif button.Title.Text == "Menu <" then
14                Sound.Pitch = 1
15                Sound:Play()
View all 23 lines...

I probably made a stupid mistake but if anyone is free to help I thank you in advance.

2 answers

Log in to vote
1
Answered by 4 years ago

Here's code with my explanation, let me know if you run into any issues.

01local MenuOpened = false -- I believe a variable might be good for this scenerio.
02 
03--[[
04Consider using InputBegan, it's widely used and easy to figure out.
05 
06If you're wondering...
07 
08UserInputType is the type of input recieved (keyboard, mouse, touch).
09UserInputState is the state of the input (begin, end, changed).
10]]
11 
12button.InputBegan:Connect(function(InputObject)
13    if InputObject.UserInputType == Enum.UserInputType.MouseButton1 or InputObject.UserInputType == Enum.UserInputType.Touch and InputObject.UserInputState == Enum.UserInputState.Begin then
14        MenuOpened = not MenuOpened
15        if not main:FindFirstChild("ContinueScreen") or (main:FindFirstChild("ContinueScreen") and main.ContinueScreen.Visible == false) then
View all 44 lines...
0
I tried your script, still doesn't work. No errors at all. I think I'll just forget having support for mobile, since it doesn't work no matter what I tried. There's probably another problem that I can't find that has to do with it. Dalamix 26 — 4y
Ad
Log in to vote
0
Answered by
Dalamix 26
4 years ago

I just changed my original event which had MouseButton1Click into MouseButton1Down. For some reason it fixed everything, found it on some roblox dev forum or something. Thanks for trying to answer my question!

Answer this question