Bouncing Projectile Similar to Super Mario's fireflower; how would I detect bounces?

I have this idea for my friend’s game, that has similar projectiles to the Fire Flower found in Super Mario Series, but I don’t know where to start. What should I use to detect when it should bounce?
Example on what I am trying to achieve
whatiwant

A “.Touched” event with a debounce lasting the duration of the bounce would be fine.

I was thinking about .Touched but I was wondering if there is any other method, however I’ll see if I can make it work how I want it to

local Fireball = script.Parent

local Floor = workspace.Floor --Example.
local Debounce = false
local Connection

Fireball.Touched:Connect(function(Hit1)
	if Debounce then
		return
	end
	
	if Hit1 == Floor then
		Debounce = true
		--Code when "Fireball" starts touching floor.
		Connection = Fireball.TouchEnded:Connect(function(Hit2)
			if Hit2 == Floor then
				--Code when "Fireball" stops touching floor.
				Debounce = false
				Connection:Disconnect()
			end
		end)
	end
end)

Just an example script. Having the “.TouchEnded” event inside the “.Touched” event is a great way to ensure that both are firing as a result of touching/not touching the same “BasePart” instance.

We disconnect the inner connection “.TouchEnded” to avoid memory leaks.

1 Like

I’ve fiddled with it for a little and it works as intended, Thank you!