Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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)

2 comments

0

It does not work.

0

Do i use lookvector?

This discussion is preserved as it was. New answers, comments, and votes are closed.