Hello. Just to get this off first, I don't really have any experience scripting in .lua. So, there's probably a lot wrong with this script. What I'm trying to do is get it so when the on button is touched, it inserts smoke and fire into the bricks listed. Right now it doesn't do that.
Model layout: http://prntscr.com/bc9zbc
Code:
local b = script.Parent.Parent.FireB local c = script.Parent.Parent.FireC local d = script.Parent.Parent.FireD local e = script.Parent.Parent.FireE local f = script.Parent.Parent.FireF local g = script.Parent.Parent.FireG local h = script.Parent.Parent.FireH local fir = Instance.new("Fire",b,c,d,e,f,g) local smo = Instance.new("Smoke",b,c,d,e,f,g) function onClicked() print "Fire on" fir = Instance.new("Fire",b,c,d,e,f,g) smo = Instance.new("Smoke",b,c,d,e,f,g) script.Parent.Parent.b.Fire.Size = 25 script.Parent.Parent.b.Smoke.Size = 20 script.Parent.Parent.b.Smoke.Color = "Black" script.Parent.Parent.b.Smoke.RiseVelocity = 3 script.Parent.Parent.c.Fire.Size = 25 script.Parent.Parent.c.Smoke.Color = "Black" script.Parent.Parent.c.Smoke.Size = 20 script.Parent.Parent.c.Smoke.RiseVelocity = 3 script.Parent.Parent.d.Fire.Size = 25 script.Parent.Parent.d.Smoke.Color = "Black" script.Parent.Parent.d.Smoke.Size = 20 script.Parent.Parent.d.Smoke.RiseVelocity = 3 script.Parent.Parent.e.Fire.Size = 25 script.Parent.Parent.e.Smoke.Color = "Black" script.Parent.Parent.e.Smoke.Size = 20 script.Parent.Parent.e.Smoke.RiseVelocity = 3 script.Parent.Parent.f.Fire.Size = 25 script.Parent.Parent.f.Smoke.Color = "Black" script.Parent.Parent.f.Smoke.Size = 20 script.Parent.Parent.f.Smoke.RiseVelocity = 3 script.Parent.Parent.g.Fire.Size = 25 script.Parent.Parent.g.Smoke.Color = "Black" script.Parent.Parent.g.Smoke.Size = 20 script.Parent.Parent.g.Smoke.RiseVelocity = 3 script.Parent.Parent.h.Fire.Size = 25 script.Parent.Parent.h.Smoke.Color = "Black" script.Parent.Parent.h.Smoke.Size = 20 script.Parent.Parent.h.Smoke.RiseVelocity = 3 end script.Parent.Touched:connect(onClicked)
You can only use two arguments in Instance.new()
. The object you want to create, and the parent of the new object.
You're also using Smoke Color improperly as it is a Color3 value, not a BrickColor (even if it was you'd need to use BrickColor.new()
)
Since it looks like you're wanting to make multiple of the same parts, what you could do is put all the parts you defined into a table. Then you would be able to use a for loop to go through all elements of the table and create the new items.
You would need to use Color3.new(r/255, g/255, b/255) since all arguments of Color3.new()
are floats they have to be between 0 and 1. Alternatively, you can use the new function Color3.fromRGB
and use whole numbers from there.
local PartsToSetAblaze = { script.Parent.Parent.FireB, script.Parent.Parent.FireC, script.Parent.Parent.FireD, script.Parent.Parent.FireE, script.Parent.Parent.FireF, script.Parent.Parent.FireG, script.Parent.Parent.FireH, --You can add more parts here. } function onClicked() print "Fire on" for Index, Value in pairs(PartsToSetAblaze) do --Index and Value are just variables. You can name these however you want. Index is the number the value is in the table. The value is the actual object or value in the table. if Value ~= nil then --We just want to make sure that the part still exists, otherwise the script may error. local fir = Instance.new("Fire",Value) --Create new fire object and put it in the brick. fir.Size = 25 --We can use the variable and change the size immediately. local smo = Instance.new("Smoke",Value) smo.Size = 20 smo.Color = Color3.new(255/255, 255/255, 255/255) --You could do 1,1,1 But I jsut wanted to emphasize that Color3.new arguments are floats and shoud be between 0 and 1. smo.RiseVelocity = 3 end end end script.Parent.Touched:connect(onClicked)