How to make Confetti appear on part Touched!

Overview :confetti_ball:

Hello, in this tutorial I will be teaching you how to make it so when a player steps on a part confetti appears above their head for a brief moment. In this tutorial we will be using a Particle Emitter, you can grab the model for the Particle Emitter below.

Confetti Model I use

https://www.roblox.com/library/7255773215/Confetti

Roblox API's Of Everything In This Script

The Setup :gear:

Step 1: You are gonna want to put your confetti in Server Storage:
image
Step 2: Add a new part into workspace, anchor it and add a server-script inside: image

The Scripting :desktop_computer:

Alright, we’re gonna get into the fun part, scripting!

First of all, we’re gonna define all our variables:

local Part = script.Parent
 -- ^ The part we walk on to trigger the confetti 
local Confetti = game:GetService("ServerStorage"):WaitForChild("Confetti") 
-- ^ The actual confetti
local Debounce = false
-- ^ Debounce so it .Touched triggered multiple times

Next, we’re gonna make a script that runs when the Part is Touched:

Part.Touched:Connect(function(hit)
-- ^ Connects function that happens when Part is touched (hit = what touches Part)
	if hit.Parent:FindFirstChild("Humanoid") then
		-- Only runs if hit is a player (Humanoid), and not anything else
	end
end)

Were finally gonna clone the confetti into the workspace and make it above the players head and add debounce:

local Part = script.Parent
-- ^ The part we walk on to trigger the confetti 
local Confetti = game:GetService("ServerStorage"):WaitForChild("Confetti") 
-- ^ The actual confetti
local Debounce = false
-- ^ Debounce so it .Touched triggered multiple times

Part.Touched:Connect(function(hit)
	-- ^ Connects function that happens when Part is touched (hit = what touches Part)
	if hit.Parent:FindFirstChild("Humanoid") then
		-- Only runs if hit is a player (Humanoid), and not anything else
		if not Debounce then
			Debounce = true
			-- ^ Debounce
			local Head = hit.Parent.Head
			-- ^ Defines the head of hit.Parent
			local ConfettiClone = Confetti:Clone()
			-- ^ Makes a variable of the cloned confetti
			ConfettiClone.Parent = workspace
			-- ^ Puts the clone in workspace
			ConfettiClone.CFrame = CFrame.new(Head.Position.X,Head.Position.Y+3,Head.Position.z)
			-- ^ Sets the clones CFrame (Position) to above players head then
			task.wait(1)
			-- ^ Waits this amount and then does debounce again
			ConfettiClone:Destroy()
			Debounce = false
			-- ^ Disables debounce, thus allowing player to do confetti again.
		end
	end
end)

Final Result

Here’s how it all came out, not the best but it’s a good little project you could do:

The End :wave:

Although this is a very simple script and definitely needs improvement, it should be a starting place for beginner scripters!

Raw script without comments:

local Part = script.Parent
local Confetti = game:GetService("ServerStorage"):WaitForChild("Confetti") 
local Debounce = false

Part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		if not Debounce then
			Debounce = true
			local Head = hit.Parent.Head
			local ConfettiClone = Confetti:Clone()
			
			ConfettiClone.Parent = workspace
			ConfettiClone.CFrame = CFrame.new(Head.Position.X,Head.Position.Y+3,Head.Position.z)
				task.wait(1)
			ConfettiClone.Parent = game.ServerStorage
			Debounce = false
		end
	end
end)
This was my first tutorial, rate it on a scale of 1/10 please!
  • 1 :poop:
  • 2 :face_vomiting:
  • 3 :yawning_face:
  • 4 :confused:
  • 5 :neutral_face:
  • 6 :slightly_smiling_face:
  • 7 :ok_hand:
  • 8 :+1:
  • 9 :smiley:
  • 10 :star_struck:

0 voters

I spent an hour making this tutorial so I hope you learned something! :joy:

7 Likes

Would mind adding an example image, gif or mp4? Some people like to see the final result.

1 Like

This is a perfect example of something done simplistically and in a way new developers can learn from, would you be interested in doing a part two incorporating some Remote Event or Magnitude checks. Thank you for this!

3 Likes