I want dribble M1 for the football to be more responsive

I wanna make dribble M1 more responsive.

The issue itself is about ball being “delayed” or something, or it doesn’t even see that leg is touching the ball.

Server Script:

local eventM1 = game.ReplicatedStorage.Folder.Folder.Folder.Folder.Events.Dribble.DribbleM1
local VectorViz = require(game.ServerStorage.Modules.ball)
local RunService = game:GetService("RunService")

eventM1.OnServerEvent:Connect(function(player)
    local character = player.Character
	local rightFoot = character:FindFirstChild("RightFoot")
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	local animm1 = game.ReplicatedStorage.Folder.Folder.Animations.Dribble.M1
    local track = humanoid:LoadAnimation(animm1)

	if not rightFoot then return end -- Ensure rightFoot exists
	
	track:Play()

	local rayDirection = character:FindFirstChild("HumanoidRootPart").CFrame.LookVector * 2 -- Increased ray length
	local raycastParams = RaycastParams.new()
	raycastParams.FilterDescendantsInstances = {character, workspace.pitch}
	raycastParams.FilterType = Enum.RaycastFilterType.Exclude
	raycastParams.IgnoreWater = true
	
	local ball = workspace.Ball
	ball:SetNetworkOwner(nil)
	
	local hitcontent = workspace:GetPartBoundsInBox(ball.CFrame, Vector3.new(1.5, 1.4, 1.5))
	local hitlist = {}
	
	for _,v in pairs(hitcontent) do
		if v.Parent:HasTag("Characters") then
			print("Ball detected by raycast")

			local horizontalVelocity = 6 -- Adjust to your liking
			local veritcalVelocity = workspace.Gravity + 2 -- Also adjust to your liking
			local vel = character.HumanoidRootPart.CFrame.LookVector * horizontalVelocity + Vector3.new(0,verticalVelocity,0)
			ball.AssemblyLinearVelocity += vel

			--// Create a beam to represent the air resistance force
			VectorViz:CreateVisualiser("AirResistance", ball.Position, Vector3.zero, {
				Colour = Color3.new(255, 0, 0),
				Width = 0.1,
				Scale = 1.5
			}
			)

			--// Update the beam to continue matching the ball's position and updating the air resistance value

			local Connection = nil

			Connection = RunService.Stepped:Connect(function()
				local AirResistance = -ball.AssemblyLinearVelocity * math.exp(ball.AssemblyLinearVelocity.Magnitude ^ 2 / 2750)

				VectorViz:UpdateBeam("AirResistance", ball.Position, AirResistance)
			end)

			task.wait(0.21)

			Connection:Disconnect()
			VectorViz:DestroyVisualiser("AirResistance") --// Okay I've had enough of visualising, lets destroy the beam

			print("Ball velocity applied:", ball.AssemblyLinearVelocity)

			task.delay(0.5, function()
				local tween = game.TweenService:Create(ball, TweenInfo.new(0.5), {AssemblyLinearVelocity = Vector3.new(0,0,0)})
				tween:Play()
				print("Ball velocity reset")
			end)
		else
			local raycastResult = workspace:Raycast(rightFoot.Position, rayDirection, raycastParams)
			print("Raycast result:", raycastResult)

			if not raycastResult or not raycastResult.Instance:HasTag("Ball") then return end
            
			print("Ball detected by raycast")

			local ball = workspace.Ball
			ball:SetNetworkOwner(nil)

			-- Ensure the ball is not anchored
			if ball.Anchored then
				ball.Anchored = false
			end

			local horizontalVelocity = 6 -- Adjust to your liking
			local veritcalVelocity = workspace.Gravity + 2 -- Also adjust to your liking
			local vel = character.HumanoidRootPart.CFrame.LookVector * horizontalVelocity + Vector3.new(0,verticalVelocity,0)
			ball.AssemblyLinearVelocity += vel

			--// Create a beam to represent the air resistance force
			VectorViz:CreateVisualiser("AirResistance", ball.Position, Vector3.zero, {
				Colour = Color3.new(255, 0, 0),
				Width = 0.1,
				Scale = 1.5
			}
			)

			--// Update the beam to continue matching the ball's position and updating the air resistance value

			local Connection = nil

			Connection = RunService.Stepped:Connect(function()
				local AirResistance = -ball.AssemblyLinearVelocity * math.exp(ball.AssemblyLinearVelocity.Magnitude ^ 2 / 2750)

				VectorViz:UpdateBeam("AirResistance", ball.Position, AirResistance)
			end)

			task.wait(0.21)

			Connection:Disconnect()
			VectorViz:DestroyVisualiser("AirResistance") --// Okay I've had enough of visualising, lets destroy the beam

			print("Ball velocity applied:", ball.AssemblyLinearVelocity)

			task.delay(0.5, function()
				local tween = game.TweenService:Create(ball, TweenInfo.new(0.5), {AssemblyLinearVelocity = Vector3.new(0,0,0)})
				tween:Play()
				print("Ball velocity reset")
			end)
        end
	end
end)

Video:

Try

Sidim ne ripaemsia

became a bit better, but still has the problem

I dont know if its possible to make it so smooth. I remember playing some footbal games and none of them had very smooth ball replication.
Sidim ne ripaemsia.

Sidim ne ripaemsia.

Try making movement prediction for ball. Like show it a little forward for clients.

Sidim ne ripaemsia.

okay I just modified ray cast and fixed it.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.