# Issues with Touch Soccer Physics

I have been in here trying to figure out this basic yet complicated problem (at least for me). What I am essentially trying to do is make it so when the soccerball is touched, the positioning of the ball will be dependent on how hard the player hit it. If I barely moved my avatar, the ball would barely move while if I was already set at 14 walkspeed from having the momentum, it would hit as hard as possible.

In which obviously I am stuck. I tried to recreate some potential solutions via a former devforum post to no avail. Do you guys have any suggestions?

I know what I am going to need is the HumanoidRootPart but that is as far as I know in regards to going along this idea…

This is the most basic implementation, way more you could (and should) add to it to make it more realistic, but it behaves like the player is kicking it, especially when you jump which increases the player velocity. And change the direction your character is looking as you play because this will alter the impulse applied.

All you need to do is add this code to a LocalScript and parent it under StarterPlayerScripts.

``````local Ball = Instance.new("Part",workspace);
Ball.CanCollide = true;
Ball.CanTouch = true;
Ball.Shape = Enum.PartType.Block;
Ball.Size = Vector3.new(1,1,1);
Ball.Position = Vector3.new(0,3,0);

local Players = game:GetService("Players");
local LocalPlayer = Players.LocalPlayer;
local Character = LocalPlayer.Character;
if not Character or not Character.Parent then
end
local Humanoid = Character:WaitForChild("Humanoid",3);
local LeftFoot = Character:WaitForChild("LeftFoot",3);
local RightFoot = Character:WaitForChild("RightFoot",3);

local MEDIUM = 20; -- this is a minimum limit of the velocity applied to the ball
local BOUNCE = 50; -- change this to make it more/less bouncy

--=================================================================================
function ApplyForce(hit)

if hit == LeftFoot or hit == RightFoot then
local footVelocity = hit:GetVelocityAtPosition(hit.Position);
local volume = math.min(footVelocity.Magnitude, MEDIUM);