Currently, I have a script that detects when you touch a button (on mobile) and then after sending a lightning bolt to a place you click on the screen after clicking the button (the two signals don’t overlap or run at same time, I checked). For some odd reason, the lightning bolt is going to around where I clicked the button and same with a part I positioned at Mouse.Hit.p. EDIT: For some reason it seems to be going where i last clicked before that.
I strongly suggest you get comfortable with using UserInputService instead of the old mouse functions if you’re going to make something mobile-focused. Otherwise you’re guaranteed to get strange results.
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if not gameProcessed then
if (input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch) then
local newPart = Instance.new("Part")
newPart.CFrame = CFrame.new(input.Position))
newPart.Parent = workspace
end
end
end)
This only creates a part on the Client’s side. If you want the Server to create the part, you’ll need to send a RemoteEvent with the position to a Server script that will create the part for you.
1 Like