Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you retrieve a target from an UDim2?

Asked by 8 years ago

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

Log in to vote
1
Answered by 8 years ago

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.

0
O ty. NathanAdhitya 124 — 8y
Ad

Answer this question