Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i make the ball go in FRONT of me, not just a vector relative to my body position? [help]

Asked by 2 years ago
Edited 2 years ago

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?

1 answer

Log in to vote
0
Answered by 2 years ago

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)
0
It does not work. TakeItToTheM 0 — 2y
0
Do i use lookvector? TakeItToTheM 0 — 2y
Ad

Answer this question