local t = 6.5;
local point = workspace:WaitForChild("Point")
local hrp = workspace:WaitForChild("Spawner"):WaitForChild("BoxBody")
local bball = workspace:WaitForChild("Box");
local function createBox(count)
for i = 1, count, 1 do
local g = Vector3.new(0, -workspace:WaitForChild("Gravity").Value, 0);
local x0 = hrp.CFrame * Vector3.new(0, 5, 5)
-- calculate the v0 needed to reach mouse.Hit.p
local v0 = (point.Position - x0 - 0.5*g*t*t)/t;
-- have the ball travel that path
local c = bball:Clone();
c.Velocity = v0;
c.CFrame = CFrame.new(x0);
c.CanCollide = true;
c.Parent = game.Workspace;
task.spawn(function()
task.wait(15)
local explosion = Instance.new("Explosion")
explosion.BlastPressure = 500000
explosion.ExplosionType = Enum.ExplosionType.Craters
explosion.BlastRadius = 20
explosion.Position = c.Position
explosion.Parent = workspace
c:Destroy()
end)
task.wait(0.1)
end
end
while task.wait(5) do
createBox(10)
end
This code moves a part from one position to another in a parabolic way using .Velocity. However how would I move a model instead of a part with .Velocity? Also do you know any other alternatives to .Velocity?
The models aren’t spawning in the red part, which is the spawner.
Here is my code:
local t = 6.5;
local point = workspace:WaitForChild("Point")
local hrp = workspace:WaitForChild("Spawner"):WaitForChild("BoxBody")
local bball = game:GetService("ServerStorage"):WaitForChild("Box");
local function createBox(count)
for i = 1, count, 1 do
local g = Vector3.new(0, -workspace:WaitForChild("Gravity").Value, 0);
local x0 = hrp.CFrame * Vector3.new(0, 5, 5)
print(x0)
-- calculate the v0 needed to reach mouse.Hit.p
local v0 = (point.Position - x0 - 0.5*g*t*t)/t;
-- have the ball travel that path
local a = bball:Clone();
local c = a:WaitForChild("BoxBody")
c.CFrame = CFrame.new(x0);
c.Velocity = v0;
print(c.CFrame)
c.CanCollide = true;
a.Parent = game.Workspace;
task.spawn(function()
task.wait(15)
local explosion = Instance.new("Explosion")
explosion.BlastPressure = 500000
explosion.ExplosionType = Enum.ExplosionType.Craters
explosion.BlastRadius = 20
explosion.Position = c.Position
explosion.Parent = workspace
c:Destroy()
end)
task.wait(0.1)
end
end
while task.wait(5) do
createBox(1)
end
When I print the Cframe, it is correct however the model still doesn’t go to that Cframe.