Dust ParticleEmitter Color From Hit Color Script Not Working

I have a LocalScript that’s supposed to change the color of the footstep dust ParticleEmitter coming from my character, based on the color of the ground I’m walking on. When I have my code running, this is the stuff I get.

while true do

wait()

local RootPart =script.Parent.HumanoidRootPart

local Ignore = script.Parent

local ray = Ray.new(RootPart.CFrame.p,Vector3.new(0,-50,0))

local Hit, Position, Normal, Material = workspace:FindPartOnRay(ray,Ignore)

if Hit then script.Parent.FootDust.Dust.Color = Hit.ColorSequence

end

end

If I use Color3 or BrickColor, it will say "ColorSequence expected, got BrickColor/Color3. This is really annoying and it grinds my gears. Please help immediately.

2 Likes

I’m not too familiar with the inner workings of ColorSequences due to the lack of documentation on them but you should be able to construct a new ColorSequence with the Color value of the part by setting the Color property to something like Dust.Color = ColorSequence.new(Hit.Color). Let me know if that works or not.

1 Like
while true do
	wait()
	local RootPart =script.Parent.HumanoidRootPart

local Ignore = script.Parent

local ray = Ray.new(RootPart.CFrame.p,Vector3.new(0,-50,0))

local Hit, Position, Normal, Material = workspace:FindPartOnRay(ray,Ignore)

if Hit then script.Parent.FootDust.Color = Color3.new(Hit.Color)
end
end

I tried this. It doesn’t work, but no errors are thrown.
When I run this in the command bar, it SAYS it works, but nothing changes. Maybe the script must be a SCRIPT and not Local.
EDIT: aight bro it won’t work we gon’ need an expert out here

1 Like

All colour values of ParticleEmitters are of the ColorSequence datatype. You are required to construct a new ColorSequence in order to set the colour of a particle emitter. See @metryy’s post.

1 Like

And yet I can’t set a Color3.New of it? Well, if a ColorSequence is what I need, then okay. EDIT: It didn’t work. I tried. It didn’t work at all.

1 Like

What doesn’t work? What code are you working with right now? Have you tried debugging this to see what your values are coming back as to confirm if they’re intended or not?

1 Like

Okay, okay, so. Here it is.
image

1 Like

Wrap the Color3.new() in a ColorSequence.new()

You can also insert two Color3 values or an array inside too.

1 Like

I tried it. It doesn’t work, I’ve tried everything.

1 Like

It would help if you told me the error you got, rather than just saying it didn’t work.

1 Like

“Color3 expected, got ColorSequence”
Or
“ColorSequence expected, got Color3”
It keeps doing that to me.

1 Like

For my really old and outdated gun system, I did this:

Particle.Color = ColorSequence.new(HitPart.BrickColor.Color)

‘HitPart’ is the part that was hit by the ray. I tested my code just now and it works fine, see if this method works for you!

2 Likes

You didn’t post the code you were working with and you were told several times how to make this work. You are also not providing information every time the script supposedly doesn’t work for you at all; no console errors, no updated code, nothing. You need to supply information at any point while working with others to resolve your problem.

The Color value of a ParticleEmitter only accepts a ColorSequence object. ColorSequence objects must be constructed in either three ways:

  1. With a single Color3 value which serves as the start and end gradient colour
  2. With two Color3 values that define the start and end colours of the gradient
  3. With a table of ColorSequenceKeypoint objects that construct a gradient

Wrap the baseplate colour in a ColorSequence and assign it to the ParticleEmitter’s colour. If it doesn’t work and you reply as such, PLEASE PROVIDE INFORMATION SUCH AS YOUR UPDATED CODE.

2 Likes

@Kord_Kimage

1 Like

Can you post all of your code?

1 Like
while true do
	wait()
	local RootPart =script.Parent.HumanoidRootPart

local Ignore = script.Parent

local ray = Ray.new(RootPart.CFrame.p,Vector3.new(0,-50,0))

local Hit, Position, Normal, Material = workspace:FindPartOnRay(ray,Ignore)

if Hit then script.Parent.FootDust.Color = ColorSequence.new(Hit.BrickColor.Color)
end
1 Like
if Hit then script.Parent.FootDust.Color = ColorSequence.new(Hit.Color)
end

try that

1 Like

You may use color3.FromRGB like this:

if Hit then script.Parent.FootDust.Color = Color3.FromRGB(Hit.Color)

end
1 Like

script.Parent.FootDust.Color = Hit.Color
Should work just fine because the Color property already has a Color Sequence @GamerBoi98730

1 Like

I’ve had the same issue before, I guarantee this will work:

Dust.Color = ColorSequence.new {
	ColorSequenceKeypoint.new(0, Hit.Color), 
	ColorSequenceKeypoint.new(1, Hit.Color)
}