Simple Confetti Effect

Demos

Sample Code
local UserInputService = game:GetService("UserInputService")
local Confetti = require(game:GetService("ReplicatedStorage").Confetti)

local CONFETTI_INFO = Confetti.NewInfo(
	true,
	25,
	0.1,
	5,
	0.1,
	0,
	0.01,
	0,
	10
)

UserInputService.InputBegan:Connect(function(inputObject)
	if inputObject.KeyCode == Enum.KeyCode.Q 
		and inputObject.UserInputState == Enum.UserInputState.Begin
	then
		Confetti.Create(CONFETTI_INFO, UDim2.new(0.5, 0, 0.5, 0))
	end
end)

What is is?

This is a super simple module I wrote awhile ago for creating confetti effects that I thought I’d share. Although the first demo uses static values, it also supports NumberRange’s and NumberSequence’s which were used in the second example. If you do want to use NumberRange’s and NumberSequences with the module, which I would recommend as they make nicer results, then I would also recommend creating a placeholder object with attributes to make editing these easier. This module should be used on the client side, and it also creates a new ScreenGui called Effects parented to the player’s PlayerGui in order to display the confetti effect.

Example of using attributes


Documentation

Documentation

Confetti.NewInfo(useScale, amount, size, lifetime, speed, rotation, spreadRadius, transparency, rotSpeed, creationDelay, zIndex): ConfettiInfo

This function creates a new ConfettiInfo object describing to Confetti.Create() what the effect should look like.

Confetti.NewInfo()

useScale: boolean

(Defaults to true) This determines whether or not the size, speed, and spreadRadius properties use scale or offset values.

amount: number

(Defaults to 1) This determines the amount of confetti pieces that will be created.

size: number | NumberSequence

(Defaults to 1) This determines the size of each confetti piece, if useScale is true then this will be a percentage of the shortest axis of the screen, or if useScale is false then it is the pixel size. If this is a number sequence, then this will determine the size of the confetti pieces over time, with 0 representing confetti's initial size, and 1 representing the confetti's size immediately before it disappears.

lifetime: number | NumberRange

(Defaults to 1) This determines how long in seconds each piece of confetti will last. Alternatively, if a NumberRange is used instead, then the lifetime of each individual piece of confetti will be somewhere between the min and max values.

speed: number | NumberRange

(Defaults to 0) This is how far each piece of confetti will move along the screen each second, measured in either percentage of the screen or pixels depending on the value of useScale. If a NumberRange is used, then the individual speed of each confetti will be a random value between the min and max of the NumberRange.

rotation: number | NumberRange

(Defaults to 0) This is the starting rotation of each piece of confetti when they are initially created, measured in degrees. If a NumberRange is used, then a random number between min and max is chosen for each piece of confetti.

spreadRadius: number

(Defaults to 0) This is how far from the centre of the confetti's creation that pieces can start. This is measured in either percentage of the screen or pixels, depending on the value of useScale. This can be helpful if you feel that the confetti is too cramped together right when it's initially created as this can help spread it out.

transparency: number | NumberSequence

(Defaults to 0) This determines the transparency of each piece of confetti, with 0 being completely opaque, and 1 being completely transparent. If a NumberSequence is used instead, then it will represent the transparency of each piece of confetti over time, with being the confetti's initial transparency, and 1 being its final transparency.

rotSpeed: number | NumberRange

(Defaults to 0) This determines how quickly each piece of confetti will rotate, measured in degrees per second. Alternatively, if a NumberRange is used, then instead a random value between min and max will be chosen for each piece of confetti's rotation speed.

creationDelay: number

(Defaults to 0)

When set to a non-zero value, this property will delay the creation of each piece of confetti by the given amount of seconds, creating each piece one by one. IMPORTANT: Using this will yield the current thread, so use task.spawn() or some similar method if you don't want the rest of your code to yield until all of the confetti is created. Additionally, this property supports values smaller than the heartbeat, in which case the module will simply create multiple pieces of confetti in a single heartbeat.

zIndex: number

(Defaults to 1) This property determines the ZIndex property of each piece of confetti created using this ConfettiInfo, allowing you to control how multiple confetti effects played at the same time layer on top of each other.

Return: ConfettiInfo

This returns a ConfettiInfo describing to Confetti.Create() what the confetti effect should look like.

Confetti.Create(confettiInfo, originPoint): nil

This method creates the actual confetti effect, displaying it to the player.
Confetti.Create()

confettiInfo: ConfettiInfo

This is the ConfettiInfo object that describes to the module what the confetti effect should look like, created using Confetti.NewInfo(), see there for more information on how to customise the effect.

originPoint: UDim2

This is the location on screen that the confetti effect will be created at. Note that this is not impacted by ConfettiInfo.useScale.


Module

This module is available for free here.
Adding new features to this isn’t a priority for me right now, but feel free to suggest things anyways and I might add them. The exception to this is bug fixes, if you find any bugs in the module, please let me know and I’ll try to fix them as soon as possible.


Other Stuff by Me

Here's some other stuff I've made

Path3D: A 3d version of the Path2D apis.

3 Likes