Setting particles error

I’m trying to set particles when I use a move, but I’m getting an error image
I don’t want it to change as it goes, I just want the size, transparency to stay the same etc.
heres my code

		local particle1 = Instance.new("ParticleEmitter",playerWhoFired.Character["Right Arm"])
		local particle2 = Instance.new("ParticleEmitter",playerWhoFired.Character["Left Arm"])
		local particle3 = Instance.new("ParticleEmitter",playerWhoFired.Character["Right Leg"])
		local particle4 = Instance.new("ParticleEmitter",playerWhoFired.Character["Left Leg"])
		particle1.Texture = "rbxassetid://288049555"
		particle2.Texture = "rbxassetid://288049555"
		particle3.Texture = "rbxassetid://288049555"
		particle4.Texture = "rbxassetid://288049555"
		particle1.Size = 0.3
		particle2.Size = 0.3
		particle3.Size = 0.3
		particle4.Size = 0.3
		particle1.LightInfluence = 0.5
		particle2.LightInfluence = 0.5
		particle3.LightInfluence = 0.5
		particle4.LightInfluence = 0.5
		particle1.Transparency = 0.3
		particle2.Transparency = 0.3
		particle3.Transparency = 0.3
		particle4.Transparency = 0.3
1 Like

What’s line 35 of your script?

		particle1.Size = 0.3

I didnt show the entire script, cause it’s unrelated

The size value is a number sequence, not a number. You can create a number sequence by doing NumberSequence.new(number, number)

1 Like

how would it work? i don’t want it to change as it goes, i want it to stay static as those stats.

You’ll need to experiment with the two values that you want. You can’t set a single number as their are two parts to the size.

You would just put the same number in. It just has to be in the numbersequence format. For example, NumberSequence.new(1, 1) would keep the size as 1. NumberSequence.new(1, 2) would grow. NumberSequence.new(1, 0) would shrink.

Would it be the same for color? I fixed the past error but I get a new error from here

		particle1.Color = ColorSequence.new(255,0,0, 255,0,0)
		particle2.Color = ColorSequence.new(255,0,0, 255,0,0)
		particle3.Color = ColorSequence.new(255,0,0, 255,0,0)
		particle4.Color = ColorSequence.new(255,0,0,  255,0,0)

image

Yes it would be the same, also I suggest maybe using for loops to shorten that code.

You need to put color3 values, your just giving it a table of numbers. That’s why it’s erroring.

what do you mean?

(limit of charr

A ColorSequence requires Color3 values. For example, ColorSequence.new(Color3.new(1,1,1), Color3.new(0,0,0)). This will go white to black.

You are giving it a table of numbers: ColorSequence.new(1,1,1,0,0,0). This will not work.

1 Like

Color sequence is created like so:

ColorSequence.new{ColorSequenceKeypoint.new(Color3, 0), ColorSequenceKeypoint.new(Color3, 1)}
                 ^ Notice the curly brackets

Number sequence is similar, but with different names:

NumberSequence.new{NumberSequenceKeypoint.new(Value, 0), NumberSequenceKeypoint.new(Value, 1)}
                  ^ Notice the curly brackets

Thank you! One last thing, it won’t let me disable the particles like so:

	local function stopParticles()
		particle1:Destroy()
		particle2:Destroy()
		particle3:Destroy()
		particle4:Destroy()
		particle1 = nil
		particle2 = nil
		particle3 = nil
		particle4 = nil

image

I see that inside the first script that your defining the particles as a local variable. If you have a local variable in one function and inside of a separate function try to call it, it would error. Try setting them as a global variable, and define the’local particle1’ at the top of the script and call from that.

That’s exactly what I did, I put these at the top

local particle1 
local particle2 
local particle3 
local particle4

Your still calling it local inside of the function where your creating it which causes other functions to not be able to see it.

1 Like

12:48:52.269 - ServerScriptService.Scripts.FlipServer:64: attempt to index nil with ‘Destroy’
It happened again

	local function setParticles()
		
		 particle1 = Instance.new("ParticleEmitter",playerWhoFired.Character["Right Arm"])
		 particle2 = Instance.new("ParticleEmitter",playerWhoFired.Character["Left Arm"])
		 particle3 = Instance.new("ParticleEmitter",playerWhoFired.Character["Right Leg"])
		 particle4 = Instance.new("ParticleEmitter",playerWhoFired.Character["Left Leg"])
		particle1.Texture = "rbxassetid://288049555"
		particle2.Texture = "rbxassetid://288049555"
		particle3.Texture = "rbxassetid://288049555"
		particle4.Texture = "rbxassetid://288049555"
		particle1.Size = NumberSequence.new(0.3, 0.3)
		particle2.Size = NumberSequence.new(0.3, 0.3)
		particle3.Size = NumberSequence.new(0.3, 0.3)
		particle4.Size = NumberSequence.new(0.3, 0.3)
		particle1.LightInfluence = NumberSequence.new(0.5, 0.5)
		particle2.LightInfluence = NumberSequence.new(0.5, 0.5)
		particle3.LightInfluence = NumberSequence.new(0.5, 0.5)
		particle4.LightInfluence = NumberSequence.new(0.5, 0.5)
		particle1.Transparency = NumberSequence.new(0.3, 0.3)
		particle2.Transparency = NumberSequence.new(0.3, 0.3)
		particle3.Transparency = NumberSequence.new(0.3, 0.3)
		particle4.Transparency = NumberSequence.new(0.3, 0.3)
		particle1.Color = ColorSequence.new(Color3.new(255,0,0), Color3.new(255,0,0))
		particle2.Color = ColorSequence.new(Color3.new(255,0,0), Color3.new(255,0,0))
		particle3.Color = ColorSequence.new(Color3.new(255,0,0), Color3.new(255,0,0))
		particle4.Color = ColorSequence.new(Color3.new(255,0,0), Color3.new(255,0,0))
		particle1.EmissionDirection = Enum.NormalId.Back
		particle2.EmissionDirection = Enum.NormalId.Back
		particle3.EmissionDirection = Enum.NormalId.Back
		particle4.EmissionDirection = Enum.NormalId.Back
		particle1.Rate = 4
		particle2.Rate = 4
		particle3.Rate = 4
		particle4.Rate = 4



	end
	local function stopParticles()
		particle1:Destroy()
		particle2:Destroy()
		particle3:Destroy()
		particle4:Destroy()
		particle1 = nil
		particle2 = nil
		particle3 = nil
		particle4 = nil
end

It seems like it’s running multiple times? but still removes the particles