Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My cannon is not working if I walk over the stepped pad. What is the mistake in the script?

Asked by 6 years ago

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?

0
:connect is deprecated, use :Connect instead. AdvancedCode 136 — 6y
0
still doesn't work Lolamtic 63 — 6y
0
I think the problem is that the Fireball from the Serverstorage Wont spawn Lolamtic 63 — 6y
0
I'd suggest "workspace" instead of "game.Workspace" and "game:GetService()" for server storage. Programical 653 — 6y
View all comments (3 more)
0
Got any errors? gitrog 326 — 6y
0
+Progamical i did it but it does not work local fireball = game:GetService() fireballCopy.Parent = workspace Lolamtic 63 — 6y
0
Is this a server script? (it should be). Are you touching the pad? Are there errors in output? Did you try debugging? cabbler 1942 — 6y

Answer this question