Making a particle emitter emit for 1 second after touching a part

so i have this WORKING script to refresh the player character at the current location with a cooldown. i have made a particle emitter and want it so when you refresh the character the particle emitter plays for 1 second and then stops. tell me the locations i need to put them in after giving script too

local Players = game:GetService("Players")
local TPDest = workspace.Washer
local cooldown = false
local cooldowntimer = 6 -- Change this to whatever you want the cooldown to be

script.Parent.Touched:Connect(function(partTouched)
	if partTouched.Parent:FindFirstChild("Humanoid") and not cooldown then
        cooldown = true
		local Character = partTouched.Parent
		local Player = Players:GetPlayerFromCharacter(Character)
        Player:LoadCharacter()
        Player.Character:WaitForChild("HumanoidRootPart").CFrame = TPDest.CFrame
        if Player.Character:FindFirstChild("ForceField") then Player.Character:FindFirstChild("ForceField"):Destroy() end
        wait(cooldowntimer)
        cooldown = false
	end
end)
1 Like

There’s lacking a lot of info but… Here you go

local Players = game:GetService("Players")
local TPDest = workspace.Washer
local cooldown = false
local cooldowntimer = 6 -- Change this to whatever you want the cooldown to be
local particletimer=1
local Particles=--path for your particles here

script.Parent.Touched:Connect(function(partTouched)
	if partTouched.Parent:FindFirstChild("Humanoid") and not cooldown then
        cooldown = true
		local Character = partTouched.Parent
		local Player = Players:GetPlayerFromCharacter(Character)
        Player:LoadCharacter()
  Particles.Enabled=true
delay(particletimer,function() Particles.Enabled=false end) 
Player.Character:WaitForChild("HumanoidRootPart").CFrame = TPDest.CFrame
        if Player.Character:FindFirstChild("ForceField") then Player.Character:FindFirstChild("ForceField"):Destroy() end
        wait(cooldowntimer)
        cooldown = false
	end
end)

Edit:added a variable so you can modify the particle timer :slight_smile:

1 Like

this all works! just one question, the refresh happens a bit early and then the particles come late, could it be possible for a delay on the refresh? not on the particles though

Sorry for the waiting time had to do something :sweat_smile:

local Players = game:GetService("Players")
local TPDest = workspace.Washer
local cooldown = false
local cooldowntimer = 6 -- Change this to whatever you want the cooldown to be
local particletimer=1
local refreshtimer=1
local Particles=--path for your particles here

script.Parent.Touched:Connect(function(partTouched)
	if partTouched.Parent:FindFirstChild("Humanoid") and not cooldown then
        cooldown = true
		local Character = partTouched.Parent
		local Player = Players:GetPlayerFromCharacter(Character)
Particles.Enabled=true
delay(particletimer,function() Particles.Enabled=false end)
delay(refreshtimer,function()
        Player:LoadCharacter()
Player.Character:WaitForChild("HumanoidRootPart").CFrame = TPDest.CFrame
        if Player.Character:FindFirstChild("ForceField") then Player.Character:FindFirstChild("ForceField"):Destroy() end
end)
        wait(cooldowntimer)
        cooldown = false
	end
end)

Tune the refreshtimer variable to adjust it to your likings :slight_smile:

2 Likes

Alright, I’ll test it out tomorrow to see if it works, thanks

1 Like