I am making a settings UI, and if the player could click a button to disable effects. How do I do this?
3 Likes
This is how you do it but I still don’t know how to do it?
You could use the :GetDescendants() function
For example:
local Button = TextButtonLocation
ParticlesEnabled = true
Button.MouseButton1Down:Connect(function()
for i,v in pairs(Particles) do
if v:IsA("ParticleEmitter") then
if ParticlesEnabled then
v.Enabled = false
ParticlesEnabled = false
else
v.Enabled = true
ParticlesEnabled = true
end
end
end
end)
As long as you are using a LocalScript, the particles will only be disabled / enabled on the Client.
Hope this helped!
To save performance, giving each particleemitter a tag and using the CollectionService would be better for speed and performance
I don’t know how to use the script at all?
local StoredParticles = {
IsEnabled = false,
Particles = {}
}
--Disable
for _,v:ParticleEmitter? in workspace:GetDescendants() do
if v:IsA("ParticleEmitter") then
StoredParticles.Particles[v.Name] = v.Enabled
v.Enabled = false
end
end
StoredParticles.IsEnabled = true
-- disable any added particles
workspace.DescendantAdded:Connect(function(Child)
if Child:IsA("ParticleEmitter") and StoredParticles.IsEnabled then
StoredParticles.Particles[Child.Name] = Child.Enabled
Child.Enabled = false
end
end)
-- ENABLE
for _,v in workspace:GetDescendants() do
if v:IsA("ParticleEmitter") and table.find(tostring(v), StoredParticles.Particles) then
v.Enabled = true
end
end
StoredParticles.Particles = {}
StoredParticles.IsEnabled = false
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.