I was doing a cannonball script, but the problem is when I finished and tested it..the part didn't change at all. :/ also: is it supposed to shoot the player who clicked the cannon? or do i have to input a line of code for that? (i'm kinda new to scripting :/) for this script to somewhat work i had to put it in the part that i want to be the cannon(i also used a click detector for the "part")
Script I did:
local debounce = true
local function shoot(origin)
if debounce then
debounce = false
local cannonball = Instance.new("Part")
cannonball.Shape = Enum.PartType.Ball
cannonball.Velocity = origin.CFrame.lookVector * 300 + Vector3.new(0, 30, 0)
cannonball.CFrame = origin.CFrame + Vector3.new (0, 2, 0)
cannonball.Size = Vector3.new(1.5, 1.5, 1.5)
cannonball.Parent = workspace
cannonball.Color = Color3.new(0, 0, 0)
cannonball.Material = Enum.Material.Slate
local fire = Instance.new("Fire")
fire.Parent = cannonball
fire.Size = 4
cannonball.Touched:Connect(function(hit)
local explosion = Instance.new("Explosion")
explosion.BlastRadius = 20
explosion.Position = cannonball.Position
explosion.Parent = workspace
cannonball:Destroy()
end)
game.Debris:AddItem(cannonball, 3)
wait(2)
debounce = true
end
end
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
local head = plr.Character.Head
shoot(head)
end)

15 comments
Try setting the parent property after the color and material changing
and, instead of cannonball.Touched:Connect, put cannonball.Touched:Wait(), so it will wait for the event to happen THEN put it in debris and enable the debounce.
script works fine for me :/ (WITHOUT ANY EDIT)
yeah. btw is it a localscript or is it a server script? works fine with a server script
a script lol
oh... er, it turns to a ball for me, and all the stuff described in the script. its working perfectly fine. I think you have some kind of LUA virus on your game.
:< oof
a lua virus spreads like any other virus to EVERY SINGLE BLOCK, causing lag and disorder
what script did you use for it to work?
er, a normal server script
its just that one script too ;-; but i'm not experiencing lag
you can identify a lua virus by looking at any block's children. if you see that theres a script there that is in every other block, its a lua virus.
do you use free models? i do, just to see the scripts in them to have a idea of what im trying to do then i remove them
i dont
and there isn't a script in every block either