What I mean is, is there a way to instead of having a script in a lava brick and copying it to other places I might want can I instead have one single script where it detects if it's touched.
like this
brick -script brick -script brick -script brick -script
is that a way to reduce this like:
brick brick brick brick Script(PARENT IS WORKSPACE)
You can put all of your lava parts in one model and do like this in one script:
for i,v in next,Workspace.LavaParts:GetChildren() do v.Touched:connect(function(hit) --your code end) end
Yup! In fact, I even think this is better in terms of efficiency and CPU usage. But let's not get technical and let's answer your question.
function CreateLavabrick() local new = Instance.new("Part", game.Workspace) new.Name = "Laval" new.BrickColor = BrickColor.Red() new.Anchored = true new.Touched:connect(function(p) if p.Parent:FindFirstChild("Humanoid") then p.Parent.Humanoid.Health = -1 end end) return new end -- For example, create 100 lava bricks and move them to a random location! for i = 1, 100 do local lava = CreateLavabrick() lava.CFrame = CFrame.new(Vector3.new(math.random(-100,100), 2, math.random(-100,100)) end