i want this script to point in the middle of the screen instead of the cursor pos.
game:GetService("UserInputService").InputBegan:Connect(function(daddy)
if daddy.KeyCode == key then
if debounce then return end
debounce = true
local mousePosition = mouse.Hit.p
local originPosition = origin.Position
laserFireEvent:FireServer(mousePosition, originPosition)
wait(cooldown)
debounce = false
end
end)
Try this out, I made a raycast from the Camera’s CFrame (aka the center of your screen) forward, and fired the remote with the position that it hit.
game:GetService("UserInputService").InputBegan:Connect(function(daddy)
if daddy.KeyCode == key the
if debounce then return end
local camera = game.Workspace.CurrentCamera
local cameraPosition = camera.CFrame.p
local cameraLookVector = camera.CFrame.LookVector * 1000
local raycastResult = game.Workspace:Raycast(cameraPosition, cameraLookVector, RaycastParams.new())
if raycastResult and raycastResult.Position then
debounce = true
local originPosition = origin.Position
laserFireEvent:FireServer(mousePosition, originPosition)
wait(cooldown)
debounce = false
end
end
end)