get the time difference between when you first initiated the click and when you let go of the click using os.clock, you will use this time difference for the kick duration. then you can multiply the difference to any value to make the kick power stronger.
so i now tried multiple things and a thing i have donae dosent even works
local character = script.Parent
local UIs = game:GetService("UserInputService")
local kickpo = 500
UIs.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton2 then
print("inputBegan")
local startime = tick()
UIs.InputEnded:Connect(function(input)
print("inputended")
if input.UserInputType == Enum.UserInputType.MouseButton2 then
local endtime = tick()
local duration = endtime - startime
local kickpower = kickpo * duration
local rootpart = character:FindFirstChild("HumanoidRootPart")
if rootpart then
local bodyforce = Instance.new("VectorForce")
bodyforce.Force = Vector3.new(0, kickpower, 0)
bodyforce.Parent = rootpart
wait(duration/2)
bodyforce:Destroy()
end
end
end)
end
end)
You can use a RemoteEvent to find the time a mouse is clicked; this can be done by firing the event when the mouse is pressed and is released. The duration can then be multiplied by a factor/vector3 value, and then use the vector3 value in the :ApplyImpulse() function to apply an impulse to the ball. This is true if the ball is a part. Rather than :ApplyImpulse, you could also use a bodyForce or somethin like a bodyVelocity.
I found the solution i used a bezier curve to replicate the kick effect and it is more controlable than using forces i also used a remote event ,getmouse() and userinputservice .