i would like this module method to return when the click_down function is fired / right after the connection is disconnected. how should i do this? i can’t really think of a way to do this without using events or repeat (which is extremely unoptimized.)
--Modified code from Flightworks
function service:mouse_click_request()
local camera = workspace.CurrentCamera
local end_position
local connection
connection = run_service.Heartbeat:Connect(function()
end_position = camera:ScreenPointToRay(mouse.X, mouse.Y).Origin
end)
click_down:Once(function()
connection:Disconnect()
end)
return end_position
end