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

Is There Anything like "mouse.Target" for the UserInputService event, TouchTap?

Is there anything like mouse.Target for the UserInputService event, TouchTap? I was trying to make a handcuff tool in Roblox Studio, but then I ran into a problem that it didn't work for mobile. I searched it up in the Roblox Developer Website and it gave me examples of a gui, not a touch target instance. This is the script:

local UserInputService = game:GetService("UserInputService")

local function onTap(touch, gameProcessed)
	print("Tapped")
	print(tostring(touch.Target))
end

UserInputService.TouchTap:Connect(onTap)

touch.Target prints out nil.

1 answer

✓ Accepted answer

While there is nothing quite like mouse.Target for TouchTap, I would hypothesize that you could use ScreenPointToRay in order to derive the same thing, by using the Vector2 it gives you.

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