Slow. Laggy, Ball. What?

What’s Up.

So i had This issue With my Game where the Ball goes Slowly and Laggy, It’s Definetly Not Supposed to be Slow and Laggy but For me it Is

Heres the Scripts for More info!

Local:

local hitboxsize = Vector3.new(4, 5, 4)
local uis = game:GetService("UserInputService")
local dbs = game:GetService("Debris")
local db = false
local hrp = script.Parent:WaitForChild("HumanoidRootPart")
local hitanim = script:WaitForChild("Hit")
local plr = script.Parent
local loadedanim = plr:WaitForChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(hitanim)
uis.InputBegan:Connect(function(i, gpe)
	if gpe then return end
	if db then return end
	if i.UserInputType == Enum.UserInputType.MouseButton1 then
		db = true
		local VisualHitbox = Instance.new("Part") -- For Visual Effect. Not the Actual Hitbox
		local cframe = hrp.CFrame + hrp.CFrame.LookVector * 1.3
		VisualHitbox.Size = hitboxsize
		VisualHitbox.Transparency = 0.5
		VisualHitbox.CanCollide = false
		VisualHitbox.CastShadow = false
		VisualHitbox.CanQuery = false
		VisualHitbox.Anchored = true
		VisualHitbox.Color = Color3.new(1, 0, 0)
		VisualHitbox.CFrame = cframe
		VisualHitbox.Parent = workspace
		local camera = workspace.CurrentCamera.CFrame.LookVector.Y
		local Hitbox = workspace:GetPartBoundsInBox(cframe, Vector3.new(4, 5, 4))
		game.ReplicatedStorage:WaitForChild("RemoteEvent"):FireServer(camera, Hitbox)
		loadedanim:Play(0.1)
		dbs:AddItem(VisualHitbox, 0.3)
		task.wait(0.45)
		db = false
	end
end)

Global:

game.ReplicatedStorage:WaitForChild("RemoteEvent").OnServerEvent:Connect(function(plr, camera, Hitbox)
	local hrp = plr.Character:FindFirstChild("HumanoidRootPart")
	local cframe = hrp.CFrame + hrp.CFrame.LookVector * 1.3
	local clampedcamera = math.clamp(camera, -0.5, 0.5) -- UNFINISHED
	for _, v in pairs(Hitbox) do
		if v.Name == "Ball" and v.Parent == workspace then
			local mass = v.AssemblyMass
			v.AssemblyLinearVelocity = hrp.CFrame.LookVector * 180 * mass + Vector3.new(0, 150 * mass, 0)
			v.AssemblyAngularVelocity = Vector3.new(0, 0, 0)
			if v.AssemblyLinearVelocity.Magnitude >= 50 then
				game.ReplicatedStorage.KickTooFast:FireClient(plr) -- Anti-Cheat
			end
		end
	end
end)

Okay, so I think one of the things causing the lag is that you’re sending the entire Hitbox part table to the server. If a player is inside that area, it ends up sending every limb head, torso, lower arms, upper arms, and everything else. Which is probably also slowing things down.

I’d also move the hit detection to the server. It’s harder for exploiters to mess with and it should run faster overall since the server does the physics anyway.

And the mass calculations might be the main reason the ball feels slow and laggy. Multiplying the velocity by the ball’s mass ends up producing huge numbers that Roblox like messes up, which causes the weird behavior..

Ah. I’ll try What you said… Thanks!

I Simplified it and Swapped the Hitbox to the Server and it Still Produces Lag

can you try replacing this line

with this version

v.AssemblyLinearVelocity = hrp.CFrame.LookVector * 180 + Vector3.new(0, 150, 0)

That’s what i Exactly did. But a little bit different

v.AssemblyLinearVelocity = hrp.CFrame.LookVector * 15 + Vector3.new(0, 15, 0)

Are you able to send a video of how it looks?

when i was setting up the recording i realised that the issue was not on the script itself but on other problems. i guess problem solved