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

How do you retrieve a target from an UDim2?

I know it may be confusing, or it may be stupid.

I've struggled finding a way to convert an Udim2 that is from an TouchLongPress for mobiles... So, Here's the thing. Normally with normal Computer Mouse You'd be able to do the event, and use Mouse.Target to retrieve It's target. But How can you make that possible from a Touch Event from mobile?

InputService.TouchLongPress:connect(function(coords)
	-- Coords are UDim2
	local x = coords.X
	local y = coords.Y
	if Mouse.Target then -- This... Is the problem...
		if Mouse.Target.Name == 'Water' then
			script.Parent.Visible = true
			script.Parent.Text = ('Tier: '..Mouse.Target.Rarity.Value)
			script.Parent.Position = UDim2.new(0,x+4,0,y+8)
		else
			script.Parent.Visible = false
		end
	else
		script.Parent.Visible = false
	end
end)

So, What I wanted is basically, to convert from an Udim2 that bases on the camera to give / tell an object it is pointing to.

Any help?

1 answer

✓ Accepted answer

Target

Interestingly, you still use the Mouse target if you want to get the BasePart which the TouchLongPress was directed at. The Mouse is (for compatability reasons) still directed with a touchscreen just as it would be with a mouse.

1 comment

0

O ty.

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