Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How i can put MouseClickButton in cell phone?

How can I tell the script that when the player presses the button, it is to shoot?

> local cas = game:GetService("ContextActionService")
> local plr = game.Players.LocalPlayer
> local UserInputService = game:GetService("UserInputService")
> 
> local function buttonPressFunction()
> UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1)
> end
> 
> local button = cas:BindAction("ExtraFireButton", buttonPressFunction, true,Enum.UserInputType.MouseButton1)

3 comments

0

U should use plr:GetMouse() and mouse.Button1Click, its much simpler then using UIS

0

Thank you for the tips

0

You can just mark it as the answer.

1 answer

✓ Accepted answer

You can use the InputBegan event to detect different input types.

local button = script.Parent -- example

button.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.Touch then
		print("Touch event from mobile device")
	end
end)

This also works with mouse button inputs

local button = script.Parent -- example

button.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		print("Touch event from mobile device")
	end
end)

The best thing about this is it doesn't even have to be a button. Any Gui Object will do.

2 comments

0

Thank you very much, unfortunately I can't like your comment because I have no reputation

0

Then you could help he/she by marking their post as an answer :)

This discussion is preserved as it was. New answers, comments, and votes are closed.