I am making a football game, and i want the football to be directly in front of the direction the player is looking when they touch it. How could i implement that into my code?
Bonus:
Furthermore, the ball is sort of bouncing up and down when i walk with it, how would i stop that up and down motion?
Here is a video showing everything.
https://www.youtube.com/watch?v=ewWt8pmxaxE
local ball = script.Parent local cantouch = false ball.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then cantouch = true local leftleg = hit.Parent["Left Leg"] ball.CFrame = leftleg.CFrame * CFrame.new(0, 1.5, 5) local weld = Instance.new("Weld") weld.Part0 = leftleg weld.Part1 = ball weld.C0 = leftleg.CFrame weld.C1 = ball.CFrame weld.Parent = script.Parent ball.CanCollide = false end end)
Thanks, do i use lookvector or something like that?
Try replacing
ball.CFrame = leftleg.CFrame * CFrame.new(0, 1.5, 5)
with
ball.CFrame = leftleg.CFrame + CFrame.new(0, 1.5, 5)
This might also work:
ball.CFrame = leftleg.CFrame + CFrame.new(0, 1.5, -5)