What am I doing wrong here? What is causing the ball to freeze midair for an instant?

Baseplate.rbxl (23.5 KB)

  • What does the code do and what are you not satisfied with?
    it’s suppose to be a very simple code to smoothly fire a grenade/bomb in a parabolic trajectory towards mouse.Hit.Position

  • What potential improvements have you considered?
    I have tried too many things too list here, long story short, i’ve tried various combinations of NetworkOwnership setting, cloning the handle, cloning the part from workspace, replicated storage etc.,

  • How (specifically) do you want to improve the code?
    I want to “cure” my script of the small movement glitch, causing the ball to freeze mid air before continuing as normal, it doesn’t really break the game or anything, just makes it look very ugly

local Tool = script.Parent
local E = Tool:WaitForChild("E")

local t = 0.65
local g = Vector3.new(0,-workspace.Gravity,0)

E.OnServerEvent:Connect(function(player, mousePosition)
    
    local Bomb = workspace.Handle:Clone()
    
    Bomb.CanCollide = true
    Bomb.Parent = workspace
    Bomb:SetNetworkOwner(nil)
    
    Bomb.CFrame = Tool.Handle.CFrame * CFrame.new(0,0,-2)
    Bomb.Velocity = (mousePosition - Tool.Handle.CFrame.p - 0.5*g*t*t)/t
    
end)
local Tool = script.Parent
local E = Tool:WaitForChild("E")
local debounce = {}

E.OnServerEvent:Connect(function(player, mousePosition)
	if debounce[player] == true then return end
	debounce[player] = true
	local Bomb = game.ServerStorage:WaitForChild("Bomb"):Clone()
	local t = 0.65
	local g = Vector3.new(0,-workspace.Gravity,0)
	local Math = 0.5*g*t*t
	local Velocity = (mousePosition - Tool.Handle.CFrame.p - Math)/t
	Bomb.Parent = workspace
	Bomb.Position = Tool.Handle.Position
	wait()
	Tool.Handle.Transparency = 1
	Bomb.Velocity = Velocity
	coroutine.wrap(function()
		wait(1)
		debounce[player] = false
		Tool.Handle.Transparency = 0	
	end)()
end)

P.S. Take the debounce out of the local script
Tell me if this fixes your issue, I just assumed the script was having an issue calculating the math that fast and so it stuttered for a split second (Just a guess)
Also Place the bomb in ServerStorage

debounce in local script serves to prevent excessive firing of remote events when players spam click,

no not even a calculator would stutter multiplying 4 numbers i think, some humans too, but declaring it as a variable then putting it in the next line is probably making it very slightly slower
I asked around while waiting for a response here, seems that network ownership change is causing the stutter
i don’t see how the bomb being in server storage helps, or anywhere for that matter,

using your script has no effect for the first 10 or so throws, then suddenly idk why network ownership of the bomb starts being assigned to the player and it’s smooth, thank you tho, for taking the time

The other fixes I did were not to help fix the stuttering of the script but are things you should do for security reasons, hackers can spam remote events and bypass local script debounces, they can also duplicate any thing in replicatedStorage, so serverStorage is where you put things your gonna clone, I’ve never had a problem with networkOwnership which is why I find it weird. Though if my script didn’t help with stuttering, my bad, when I tested it, it had seem fine.

yes indeed, hackers are a problem, but for non hackers, i add a debounce in client as well, ofc this is a test script focused solely on the issue, so i didn’t add it in the server side, the serverstorage was a good point tho, i shall move it, i did finally find a solution I hope

Bomb = Tool.Handle:Clone()
	Bomb.CFrame = Tool.Handle.CFrame
	Bomb.Parent = workspace
	Bomb:SetNetworkOwner(player)

this is how my script looks now, i just set the ownership to player and seems for now at least that this works with 2 players at least, hopefully it will work with a full server as well, thank you again for all the help