I want to make a cannon that shoots cannonballs but the thing is, the cannonball actually doesn't move! I had a few advice, but nothing that I know of that could easily help me. This is the code that I'm using:

local Cannon = script.Parent
local CannonBody = Cannon.Union
local Cannonball = game.Workspace.MiniGame1.Cannonball
local Wall = game.Workspace.MiniGame1.Wall
local GameStart = false
local x = 14.5
local y = 3.312
local z = -72.5

function Cannonfire()
	if GameStart == true then
		local Clone = Cannonball:Clone()
		Clone.Position = Vector3.new(x, y, z)
		repeat
			wait(.5)
			y = y + .152
			z = z - 1
			Clone.Position = Vector3.new(x, y, z)
		until Wall.Touched == true
		if Wall.Touched == true then
			Clone:Destroy()
		end
	end
end
wait(5)
GameStart = true
Cannonfire()

Any help is appreciated! PS the cannonball is anchored.

4 comments

0

Use BodyVelocity instead of Position. This video helped me out, https://www.youtube.com/watch?v=Ef5z8me7mBM, skip to 12:40

0

Toolbox > ROBLOX sets > Weapons > Rocket launcher. Study it.

0

The Clone has to be unanchored when it is fired, also if the script is a local script, change it to just a script

0

I'll try those. Thanks for the help!