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