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

Cannon ball not changing firing position? [FIXED]

Asked by 6 years ago
Edited 6 years ago
c = script.Parent.click
debounce = true


pp = script.Parent.Barrel.Position


script.Parent.click.ClickDetector.MouseClick:connect(function()
    if debounce == true then c.BrickColor = BrickColor.new("Really red")
        debounce = false

        b = Instance.new("Part", game.Workspace)
        f = Instance.new("BodyThrust", b)
        fire = Instance.new("Fire", b)
        b.Name = "Canon Ball"
        b.BrickColor = BrickColor.new("Really black")
        b.Shape = "Ball"
        b.Size = Vector3.new(2, 2, 2)
        b.Position = Vector3.new(pp.X , pp.Y , pp.Z + 2.5)
        f.Force = Vector3.new(0, 0, 10000)

        b.Touched:connect(function(hit)
                if hit.Parent then if hit.Parent.Name == barrel then
                    print "h"
                end
                else
                    e = Instance.new("Explosion", b)
                    e.Position = b.Position
                    b:Destroy()
                    print(hit.Name)
                end
        end)


        wait(5)
        debounce = true
        c.BrickColor = BrickColor.new("Bright green")
    end
end)

It fires where the cannon was when the game first loaded and not where the cannon is at the moment. I tried to use a while true do loop for the position but it didnt run because it was doing the loop. - Thanks

1 answer

Log in to vote
0
Answered by 6 years ago

Sorry guys im stupid I found out that the variable was declared outside the function and put pp in the function. Ill hesitate before posting here in the future.

0
If you could edit your question so it says [Fixed] so that others know you don't need help. Greatly appreciated. Troidit 253 — 6y
0
Done birdeater11 14 — 6y
Ad

Answer this question