How i make the player kick a ball?

i’m making a football game and i made the script to player take the ball but i cant make they kick the ball in direction of the character is looking.

this is the script

local player = game.Players.LocalPlayer

local mouse = player:GetMouse()

local Who = game.ReplicatedStorage.HoldingBall.Who

local holding = false

mouse.Button1Down:Connect(function()
	
	if Who.Value == player.Character then
		holding = true
		script.ThrowForce.Value = script.ThrowForce.Value + 15
		print("in")
		task.wait(0.2)
		repeat script.ThrowForce.Value = script.ThrowForce.Value + 15 wait() until  holding == false

	end

end)

mouse.Button1Up:Connect(function()
	
	if holding == true then
		if Who.Value == player.Character then
			game.Workspace.Ball.BallAttach.Part0 = nil
			local humanoidvctr = player.Character.HumanoidRootPart.CFrame
			task.wait(0.1)
			local force = Instance.new("VectorForce")
			force.Parent = game.Workspace.Ball
			force.Attachment0 = game.Workspace.Ball.Attachment
			force.ApplyAtCenterOfMass = true
			force.Force = Vector3.new(script.ThrowForce.Value * humanoidvctr.LookVector) --my problem is here
			print("out")
			holding = false
			Who.Value = nil
			task.wait(0.2)
			script.ThrowForce.Value = 0
			force:Destroy()
		end
	end

end)


i’m new using body forces

2 Likes

Just do the root lookvector an then multiply it by the amount of force you want

force.Force = root.CFrame.LookVector * FORCE

realy works!! but for some reason now everytime my character walk the ball moves and when they stop the ball stop too, and for some reason they go a little bit from the left and not only from front

1 Like

Yeah this is because it reading your characters lookvector, do you happen to have it inside of a loop?

has any way to take only the values of the direction that the character is turned? and no ins’t inside of a loop