Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to change a ParticleEmitter's color by scripting?

Asked by
snarns 25
7 years ago

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

Log in to vote
3
Answered by 7 years ago
Edited 7 years ago

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.

0
Thanks for the help! snarns 25 — 7y
0
tysm LEADERFORXXDDPL 0 — 3y
Ad
Log in to vote
0
Answered by 7 years ago

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.

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago
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.

Answer this question