The title says it, how do I convert mousebutton1down to something I can use on mobile? I searched for so long an the topics didn’t help me.
Thank you in advance
if u want a small button u can use ContextService, if u want i ca help u
No, I’m not using a UI, I just need to know how to detect the mouse going down but on mobile(like when they tap the screen
MouseButton1Down works for both mobile and computer
on a GUI or only on the screen? on GUi only use MouseButton1Click on Screen use player:GetMouse()
on the screen, but there is no mouse on mobile
you can try, im sure it will work
I believe you could just use the context Action service or just even MouseButton1Click also Guiobjects have events for taping, swiping etc.
https://developer.roblox.com/en-us/api-reference/event/GuiObject/TouchTap
but its not a gui that I am trying to have the detection
The UserInputService Has this:
https://developer.roblox.com/en-us/api-reference/event/UserInputService/TouchTap
This is my problem:
as you can see i am constantly tapping and the animation wont play in the second video
show us your script, it works , if it doesnt you can get user input service
local UserInputService = game:GetService("UserInputService")
-- The parent of this script (a ScreenGui)
local touchScreenGui = script.Parent
-- Create the GUI frame that the user interacts with through Touch
-- events
local touchGui = Instance.new("Frame")
touchGui.Name = "TouchGui"
touchGui.AnchorPoint = Vector2.new(0.5, 0.5)
-- Fires when the touches their device’s screen
local function TouchTap(touch, gameProcessedEvent)
touchGui.Parent = touchScreenGui
touchGui.Position = UDim2.new(0, touch.Position.X, 0, touch.Position.Y)
touchGui.Size = UDim2.new(0,50,0,50)
end
-- Fires when a user starts touching their device's screen and does not
-- move their finger for a short period of time
local function TouchLong(touchPositions, state, gameProcessedEvent)
touchGui.Size = UDim2.new(0,100,0,100)
end
-- Fires when the user moves their finger while touching their device's
-- screen
local function TouchMove(touch, gameProcessedEvent)
touchGui.Position = UDim2.new(0, touch.Position.X, 0, touch.Position.Y)
end
-- Fires when the user stops touching their device's screen
local function TouchEnd(touch, gameProcessedEvent)
touchGui.Parent = nil
touchGui.Size = UDim2.new(0,50,0,50)
end
-- Only use the Touch events if the user is on a mobile device
if UserInputService.TouchEnabled then
UserInputService.TouchTap:Connect(TouchTap)
UserInputService.TouchLongPress:Connect(TouchLong)
UserInputService.TouchMoved:Connect(TouchMove)
UserInputService.TouchEnded:Connect(TouchEnd)
end
–using guiobject.touchtap:connect
I just have to modify this part:
if Input.UserInputType == Enum.UserInputType.MouseButton1 or --TapEvent then
I believe what you’re looking for is UserInputType.Touch
.
You can view all the UserInputTypes here.