- What do you want to achieve? Keep it simple and clear!
result in different positions in different places while “clicking” on the mobile version, as it should be without the emulation.
- What is the issue? Include screenshots / videos if possible!
I took a script already provided in roblox dev and for some reason it doesn’t work correctly in the mobile versions. Without using studio emulation the script works normally, updating the positions as I click in different places. however, I went to the emulation in roblox studio to test the mobile version and I was surprised that the results were repeating 2 times even when clicking in different places.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I saw few articles talking about this function, almost none was about the mobile version
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
local camera = workspace.CurrentCamera
--This will create a cube facing centered at the origin of the [[Ray]] returned and facing in the same direction. The center of the cube will be one stud in front of the camera.
mouse.Button1Down:Connect(function()
local ray = camera:ScreenPointToRay(mouse.X, mouse.Y, 1)
local cube = Instance.new("Part")
cube.Size = Vector3.new(1, 1, 1)
cube.CFrame = CFrame.new(ray.Origin, ray.Origin + ray.Direction)
cube.Anchored = true
cube.Parent = workspace
end)