local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local humanoid = player.Character:FindFirstChild("Humanoid")
local animate
local par = humanoid.Parent:WaitForChild("LeftHand")
local db = false
local ball = game.ReplicatedStorage.Energy
local function shootenergy()
wait(0.03)
local clone = ball:Clone()
clone.Parent = par
clone.Position = par.Position
wait(0.2)
ball.Position = Vector3.new(mouse.Hit.p)
end
mouse.KeyDown:Connect(function(key)
if key == "c" then
local animation = Instance.new("Animation", player.Character)
animation.AnimationId = "rbxassetid://5482423295"
animate = humanoid:LoadAnimation(animation)
animate:Play()
shootenergy()
game.ReplicatedStorage.Event.AddEnergy:FireServer()
db = true
wait(1)
db = false
end
end)
So basically, the script is supposed to make a ball move from the players hand to the mouse position in the 3d space. But it starts at the player and stops while the script stops from the calling of the function. Please help.

5 comments
learn roblox magnitude i think it will help
OK, thanks
Roblox does not recommend that you use mouse.KeyDown. Use UserInputService instead.
It has been working well with all my scripts, but OK then
I believe you can use mouse.Hit in order to move to an object in 3D Space. Also if you're trying to make from point A to point B, then use your starting position and mouse.Hit