How to make a projectile that shoots vertically and inclines down onto the ground

The to is the final position of the ball. And yes, under the until statement.

Edit: Oh wait, actually, since the HumanoidRootPart is above the ground, we will have to subtract its position.

local splatPosition = to - Vector3.new(0,3,0)

How would I do this with a model? It also won’t look very clean if it isn’t rotating to look like its falling.

You would use Model:PivotTo(CFrame.new(splatPosition)).

For the rotating part, add this above the repeat.

part.CFrame = CFrame.lookAt(from, to)
local rotateSpeed = math.pi * 2 -- How many rotations per second

Edit the 2 in rotateSpeed
And add this below the repeat

part.CFrame *= CFrame.Angles(-rotateSpeed,0,0)

Not from doesn’t work. It cant get the position of a model. So to move the model, I would put this under the repeat function?
part:PivotTo(CFrame.new(l0:Lerp(l1,t)))

For the from I am doing script.Parent.Position, but now since it is a model it doesnt have just a position.

If it is a model, you will use Model:PivotTo(CFrame.new( Position )) to move. And you will use Model:GetPivot to get the position

Since you said the ball is now a model, almost everything changes. Can you replace your whole code with this.

local run = game:GetService("RunService")
local function MoveBall()
	local players = game.Players:GetPlayers()
	local target = players[math.random(1,#players)]
	local part = script.Parent
	local char = target.Character or target.CharacterAdded:Wait()
	local hrp = nil
	if char then
		hrp = char:WaitForChild("HumanoidRootPart")
	end
	local from = part:GetPivot().Position
	local to = hrp.Position
	local mid = Vector3.new(to.X,from.Y,to.Z)
	local l0, l1 = nil, nil
	local t = 0
	local lookAt = CFrame.lookAt(from, to).Rotation
	local rotateSpeed = math.pi * 2 -- How many rotations per second
	repeat local dt = run.Heartbeat:Wait()
		t += dt
		l0 = from:Lerp(mid,t)
		l1 = mid:Lerp(to,t)
		part:PivotTo(lookAt*CFrame.Angles(rotateSpeed*t,0,0)+l0:Lerp(l1,t))
	until t > 1
	local splatPosition = to - Vector3.new(0,3,0)
end

MoveBall()

It’s not really a ball, I will show you a picture, it does not look good when it spins, I meant that it just follows the player. Also is there a way to make it a little slower? It is kind of fast.

local run = game:GetService("RunService")

local rotateSpeed = math.pi * 2 -- How many rotations per second
local moveTime = 4 -- How many seconds to reach the end
local function MoveBall()
	local players = game.Players:GetPlayers()
	local target = players[math.random(1,#players)]
	local part = script.Parent
	local char = target.Character or target.CharacterAdded:Wait()
	local hrp = nil
	if char then
		hrp = char:WaitForChild("HumanoidRootPart")
	end
	local from = part:GetPivot().Position
	local to = hrp.Position
	local mid = Vector3.new(to.X,from.Y,to.Z)
	local l0, l1 = nil, nil
	local t = 0
	local lookAt = CFrame.lookAt(from, to).Rotation

	repeat t += run.Heartbeat:Wait()/speed
		l0 = from:Lerp(mid,t)
		l1 = mid:Lerp(to,t)
		part:PivotTo(lookAt*CFrame.Angles(0,0,rotateSpeed*t)+l0:Lerp(l1,t))
	until t > 1

end

MoveBall()

You can edit the rotate speed and the move speed.

1 Like

Thank you so much, this really helped. I just have one more quick question; how do I make it move so that it is facing you? Right now, the back is coming towards you.

Replace this

local lookAt = CFrame.lookAt(from, to).Rotation

with this

local lookAt = CFrame.lookAt(from, to).Rotation * CFrame.Angles(0,math.pi,0)