Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to change a ParticleEmitter's color by scripting?

When a player clicks a button I want the particles to change to their color of choice. For instance, this should make it turn blue. However, I don't know the proper way of changing a ParticleEmitter's color. Help please?

local playerman = script.Parent.Parent.Parent.Parent.Parent.Character

function change()
playerman.Chest.Shatter.ParticleEmitter.Color3 = Color3.fromRGB(0, 0, 255)
wait()
end

script.Parent.MouseButton1Click:Connect(change)

3 answers

✓ Accepted answer

ParticleEmitters have keypoints, which mark intervals of change in a particle emission sequence. ROBLOX has several different ways of interacting with these special properties, which you can find on the wiki. Also, the property for color is just Color, not Color3. You can find the more information about your question on the wiki here.


As a quick demonstration, just having a constant color, you can just pass a regular Color3 value to a ColorSequence constructor.

Emitter.Color = ColorSequence.new(Color3.new(0,0,0))

Hope this cleared things up, let me know if you have any questions.

2 comments

0

Thanks for the help!

0

tysm

A ParticleEmitter does not have a property called Color3 it has a Color property which accepts the type ColorSequence.

As you are using a fixed colour you can use the constructor that requires a Color3.

Example:-

local playerman = script.Parent.Parent.Parent.Parent.Parent.Character

function change()
playerman.Chest.Shatter.ParticleEmitter.Color3 = ColorSequence.new(Color3.fromRGB(0, 0, 255))
wait()
end

script.Parent.MouseButton1Click:Connect(change)

I hope this helps.

local playerman = script.Parent.Parent.Parent.Parent.Parent.Character

function change()
playerman.Chest.Shatter.ParticleEmitter.Color3 =
ColorSequence.new(Color3.fromRGB(0, 0, 255))
wait()
end

script.Parent.MouseButton1Click:connect(change)

Keep in mind that ParticleEmitters have KeyPoints. You can look more into that on the Wiki, hope I helped.

This discussion is preserved as it was. New answers, comments, and votes are closed.