Inaccurate sphere aim

So im trying to figure out how to make this sphere go towards the ground of where my mouse position is, but it seems a little inaccurate. Any solutions? Would tweenservice work better for handling this type of stuff?


Server script

local remoteEvent = replicatedStorage:WaitForChild("RemoteEvent")
local ball = replicatedStorage:WaitForChild("Part")
local runService = game:GetService("RunService")

remoteEvent.OnServerEvent:Connect(function(player, mouseHit)
	local hrm = player.Character.HumanoidRootPart
	local cloneOfBall = ball:Clone()
	cloneOfBall.CFrame = hrm.CFrame
	cloneOfBall.Parent = workspace
	cloneOfBall.Name = "Ball"
	cloneOfBall.CanCollide = false
	cloneOfBall.Anchored = true
	
	runService.Heartbeat:Connect(function(dt)
		cloneOfBall.CFrame = CFrame.new(cloneOfBall.Position) + mouseHit.LookVector*2
	end)
end)

Can you send the LocalScript? The problem might be improper syntax there.

yep,

local UIS = game:GetService("UserInputService")
local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = replicatedStorage:WaitForChild("RemoteEvent")
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.E then
		remoteEvent:FireServer(mouse.Hit)
	end
end)

Try replacing mouse.Hit with mouse.UnitRay.Direction and see if that changes anything.

mouse.Origin will work with your current script instead of mouse.Hit. using mouse.UnitRay will make you have to change LookVector with Direction on the Server Script

I tried out both, no errors, but it’s the inaccuracy is still there

After thinking about it, you could make a tween using TweenService that tweens the sphere position to the mouse.hit.p and the time it takes be the difference between the sphere position and mouse.hit.p.

local TS = game:GetService("TweenService")
TS:Create(cloneOfBall, TweenInfo.new((cloneOfBall.Position - mouse.Hit.p).Magnitude, Enum.EasingStyle.Linear), {Position = mouse.Hit.p})