The title may be misleading but basically I’m trying to make it so that when a player touches a soccer-ball it will get launched in the direction that they touched it in. Hopefully these images will better explain what I’m trying to do
Basically, If i touch the ball with the side of my leg, It will go to the side. If I touch the ball with the front of my leg, the ball will go forwards.
This seems to work … kind of guessing on the r6, tested the r15 foot
--local script in StarterPlayer.StarterPlayerScripts
local player=game:GetService("Players").LocalPlayer
local character=player.Character or player.CharacterAdded:Wait()
local humainiod=character:WaitForChild("Humanoid") -- pause for full character load
local rightLeg=character:FindFirstChild("Right Leg") or character:FindFirstChild("RightFoot") --r6 or r15
local ball=workspace:WaitForChild("ball")
local db=true
local function onTouched(touch)
if touch~=ball or not db then return end
db=false
local contactPoint=touch.Position
local legPosition=rightLeg.Position
local offsetX=contactPoint.X-legPosition.X
local offsetZ=contactPoint.Z-legPosition.Z
if offsetX > 0.2 then print("Left side hit")
elseif offsetX < -0.2 then print("Right side hit")
elseif offsetZ > 0.2 then print("Front side hit")
end
--ball should be kicked away from above if statement above
task.wait(1) db=true --so it isn't kicked multiple times
end
rightLeg.Touched:Connect(onTouched)