Finding position of touch in touch screen

I am trying to make a mobile only game on roblox but i cant find the positions of touch when the player is multi touching and dragging. Any help?

1 Like
UserInputService:GetMouseLocation()

This would also work for touches.

1 Like

i know that this exists, I also put myself together some code

rs.RenderStepped:Connect(function()
	local c = script.Parent.Frame:Clone()
		c.Parent = script.Parent
		c.Position = UDim2.fromOffset(mouse.X, mouse.Y)

		ts:Create(c, TweenInfo.new(1), {BackgroundTransparency = 1}):Play()
		ts:Create(c, TweenInfo.new(1), {Position = UDim2.fromOffset(mouse.X+math.random(-20,20), mouse.Y+math.random(-20,20))}):Play()
		game.Debris:AddItem(c, 1)
end)

but mouse only exists in one place

Ignore this reply, it is no longer needed.

1 Like

what do you mean? i use mouse = plr:GetMouse()

Can you tell me the hierarchy of the frame and the script? (A hierarchy means how the instances are parented in the explorer. Send a screenshot.)

1 Like

it doesnt work for multi touch
:frowning:

does it matter?

image

local rs = game:GetService("RunService")
local ts = game:GetService("TweenService")
local uis = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

rs.RenderStepped:Connect(function(i, gp)
	local ml = uis:GetMouseLocation()
	local c = script.Parent.Frame:Clone()
	c.Parent = script.Parent
	c.Position = UDim2.fromOffset(ml.X, ml.Y)

	ts:Create(c, TweenInfo.new(1), {BackgroundTransparency = 1}):Play()
	game.Debris:AddItem(c, 1)
end)

You can’t rely on mouse-related functions for touchscreen enabled devices, use the ‘TouchTap’ event I provided above.

1 Like

Oh…

It does as I needed to know how to frame is parented but I now see that it’s nothing special.

If I may ask, why are you cloning the frame so many times a second? Are you making a trail of some sort?

If so, why not use the link Forummer has sent? A.K.A; use .TouchTap event?

1 Like

Look everything in here. Especially all the related things to Touch.

touchMoved worked! thanks to all of you guys who help contribute to this topic! (i reply like an npc lol)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.