warycoolio
(warycoolio)
November 30, 2020, 7:25pm
1
I’m trying to set particles when I use a move, but I’m getting an error
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?
warycoolio
(warycoolio)
November 30, 2020, 7:36pm
3
particle1.Size = 0.3
I didnt show the entire script, cause it’s unrelated
grif_0
(not_grif)
November 30, 2020, 7:45pm
4
The size value is a number sequence, not a number. You can create a number sequence by doing NumberSequence.new(number, number)
1 Like
warycoolio
(warycoolio)
November 30, 2020, 7:50pm
5
how would it work? i don’t want it to change as it goes, i want it to stay static as those stats.
WooleyWool
(AWildWooleyWool)
November 30, 2020, 7:53pm
6
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.
grif_0
(not_grif)
November 30, 2020, 7:58pm
7
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.
warycoolio
(warycoolio)
November 30, 2020, 8:05pm
8
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)
KingJoseon
(ILikeBigBananas)
November 30, 2020, 8:08pm
9
Yes it would be the same, also I suggest maybe using for loops to shorten that code.
grif_0
(not_grif)
November 30, 2020, 8:09pm
10
You need to put color3 values, your just giving it a table of numbers. That’s why it’s erroring.
grif_0
(not_grif)
November 30, 2020, 8:19pm
12
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
warycoolio
(warycoolio)
November 30, 2020, 8:22pm
14
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
grif_0
(not_grif)
November 30, 2020, 8:28pm
15
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.
warycoolio
(warycoolio)
November 30, 2020, 8:31pm
16
That’s exactly what I did, I put these at the top
local particle1
local particle2
local particle3
local particle4
grif_0
(not_grif)
November 30, 2020, 8:32pm
17
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
warycoolio
(warycoolio)
November 30, 2020, 8:50pm
18
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