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

How can I get a Position on the map with Mobile Devices?

Asked by
Uglypoe 557 Donator Moderation Voter
9 years ago

I've tried touchstarted, but it returns a screen position (which makes z=0) I want it to return a vector3 from the map for wherever they touch on their screen Any idea on how to do so?

1 answer

Log in to vote
0
Answered by 9 years ago

Assuming where they touch it moves the 'mouse' to the coords of the touch you can get the position of where they touched with mouse.Hit

local player = game.Players.LocalPlayer
local mouse = player:GetMouse() --gets the mouse
local uis = game:GetService("UserInputService")

uis.TouchStarted:connect(function()
    if mouse.Hit then --mouse.Hit is a cframe
        print('Player touched at '..mouse.Hit.p) --.p gets the position from the CFrame
    end
end)
0
Worked. Thanks! Uglypoe 557 — 9y
Ad

Answer this question