I want to make a button that when you click it, it turns off particle effects and turns them on if you click it again. I have no idea how to though and I would like the responses to be descriptive like tell me what scripts to put in each part and etc.
I made this script to delete all my fixers in my game.
repeat wait() until game:GetService("ContentProvider").RequestQueueSize == 0 function RecursiveGeneric(Parent, Func, ClassLimit) for _, Child in pairs(Parent:GetChildren()) do if not ClassLimit or Child:IsA(ClassLimit) then Func(Child) end RecursiveGeneric(Child, Func, ClassLimit) end end RecursiveGeneric( workspace, function(part) if part.Name == "Fixer" then part:Destroy() end end, "BasePart", "UnionOperation" ) script:Destroy()
The important part is this:
function RecursiveGeneric(Parent, Func, ClassLimit) for _, Child in pairs(Parent:GetChildren()) do if not ClassLimit or Child:IsA(ClassLimit) then Func(Child) end RecursiveGeneric(Child, Func, ClassLimit) end end
This is from an endorsed weld script. So if we do this:
function RecursiveGeneric(Parent, Func, ClassLimit) for _, Child in pairs(Parent:GetChildren()) do if not ClassLimit or Child:IsA(ClassLimit) then Func(Child) end RecursiveGeneric(Child, Func, ClassLimit) end end function SetAllEmitters(value) RecursiveGeneric( game.workspace, function(emitter) emitter.Enabled = value end, "ParticleEmitter" ) end
Then just use that function somewhere later in your script, like this:
SetAllEmitters(false)
This is simple, just insert this script in a function like this
function ToggleParticles() --Insert my script here end --Use the ClickDetector script thing here
Also, insert ClickDetector in your on and off button
Roblox has been changing so much, so I don't know what the current ClickDetector script is. Ok, now lets get into the script. All you need to do is call all your particle emmitters and add this after ParticleEmitter, .Enabled = false Example:
--Insert your part/brick name at Part --Insert your ParticleEmmiter name in ParticleEmmiter game.Workspace.Part.ParticleEmmiter.Enabled = false
NOTE:Make sure each brick/part is a DIFFRENT NAME or else the script might/will mess up. So basically like this
function ToggleParticles() game.Workspace.Part1.ParticleEmmiter.Enabled = false game.Workspace.Part2.ParticleEmmiter.Enabled = false game.Workspace.Part3.ParticleEmmiter.Enabled = false end
Oh, forgot to tell you to insert the script in the off button. To do the on button, do the same just with Enabled = true instead of Enabled = false. Just a example,
function ToggleParticles() game.Workspace.Part1.ParticleEmmiter.Enabled = true game.Workspace.Part2.ParticleEmmiter.Enabled = true game.Workspace.Part3.ParticleEmmiter.Enabled = true end
Hope this helps!