Im trying to do a Cannon. If u touch the stepped pad the cannon will shoot. I tried it already without a local function and without the steppedpad and it worked. But I tried to add the stepped pad and it wont work. Can anyone fix the script so it will Work?

 local cannon = script.Parent
local barrel = cannon.Barrel
local fireball = game.ServerStorage.Fireball
local steppedpad = cannon.steppedOn

local function gethit(part)
	  local parent = part.Parent
	if game.Players:GetPlayerFromCharacter(parent) then
		    local fireballCopy = fireball:Clone()
    fireballCopy.Parent = game.Workspace
    fireballCopy.Position = barrel.Position
    fireballCopy.Velocity = Vector3.new(-100,0,0)
    wait(3)
	end
end

steppedpad.Touched:connect(gethit)

I will tell you more information: the script is inside a model named Cannon. but if you stay on steppedpad then

    fireballCopy.Parent = game.Workspace
    fireballCopy.Position = barrel.Position
    fireballCopy.Velocity = Vector3.new(-100,0,0)
    wait(3)

Won't work, and the fireball won't even spawn! can anyone help me?

7 comments

0

:connect is deprecated, use :Connect instead.

0

still doesn't work

0

I think the problem is that the Fireball from the Serverstorage Wont spawn

0

I'd suggest "workspace" instead of "game.Workspace" and "game:GetService()" for server storage.

0

Got any errors?

0

+Progamical i did it but it does not work local fireball = game:GetService() fireballCopy.Parent = workspace

0

Is this a server script? (it should be). Are you touching the pad? Are there errors in output? Did you try debugging?