I have a Scanning and Extracting tool that on .Activated, until deactivated, spawns raycasts and a beam towards wherever the player’s mouse is. The attachment the beam projects towards is positioned where the raycast hits if it hits.
How do I make this mobile-compatible so you have to hold the area your scanning in order for it to succesfully scan? So far nothing happens, as expected, because holding down moves the camera.
My activation/deactivation code is:
local mouse = game.Players.LocalPlayer:GetMouse()
local joe = false --Not holding
script.Parent.Activated:Connect(function()
joe = true --Holding
while joe == true do --Fire scanning event while holding
script.Parent.Fire:FireServer(mouse.Hit.Position) --Tell event they're holding
wait(.01)
end
end)
script.Parent.Deactivated:Connect(function()
joe = false --No longer holding
script.Parent.Fire:FireServer() --Tells event they aint holding
end)
Apparantly I should be using UserInputService instead of mouse but even then I’m unsure how to make it mobile compatible.
It must be possible because a game I played used to be available on mobile and although was removed, wouldn’t have been available in the first place because the game would be unplayable without their scanner, unless it simply had different mechanics on mobile.