Hi!
I am having issues with my cannon that i scripted. This is my first time making something like this, so I don’t really know why it’s not working.
I want my cannon to clone a cannonball, and shoot it using an explosion.
Below is my code:
local CannonBall = game.ReplicatedStorage.cannonball
local Cannon = script.Parent
local CannonballOrigin = script.Parent.Shoot
local ExplosionOrigin = script.Parent.Explode
local Shoot = Cannon.Wire.ClickDetector
local HasShot = false
-- configs
local DebounceTime = 3
local BP = 50000
--Functions:
local function ShootBall()
if HasShot == false then
HasShot = true
local Ammo = CannonBall:Clone()
Ammo.Anchored = false
Ammo.Position = CannonballOrigin.Position
Ammo.Parent = game.Workspace
local Explosion = Instance.new("Explosion")
Explosion.Position = ExplosionOrigin.Position
Explosion.BlastPressure = BP
Explosion.BlastRadius = 60
Explosion.DestroyJointRadiusPercent = 0
Explosion.Parent = game.Workspace
wait(DebounceTime)
HasShot = false
end
end
Shoot.MouseClick:Connect(ShootBall)
Instead of shooting the cannonball, it does this:
Thanks in advance!