Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Cannon ball not changing firing position? [FIXED]

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

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.

2 comments

0

If you could edit your question so it says [Fixed] so that others know you don't need help. Greatly appreciated.

0

Done

This discussion is preserved as it was. New answers, comments, and votes are closed.