Okay, So I made a script that when one block is hit by a part called 'Rocket' it changes the child (removes it or changes material)
It works with one or two chains (children) but when I have many of them it's hard to list them out in a script and it gets complicated.
How can I make it so it gets the children and then changes them as a whole?
:GetChildren() only gives a read-only output, so how can I accomplish this?
Script that works with two chains:
local buttonPressed = false
Hits = script.Parent.Hits
Chain1 = script.Parent.Parent.Chain1
Chain2 = script.Parent.Parent.Chain2
function checkhits()
Hits = Hits
end
script.Parent.Touched:connect(function(bang)
if not buttonPressed then
buttonPressed = true
if bang.Name == "Rocket" then
Hits.Value = Hits.Value + 1
wait(1)
buttonPressed = false
end
end
end)
while true do
wait(0.1)
checkhits()
if Hits.Value == 1 then
Chain1.Material = "Marble"
Chain2.Material = "Marble"
elseif Hits.Value == 2 then
script.Parent:Destroy()
Chain1.Material = "CorrodedMetal"
Chain2.Material = "CorrodedMetal"
Chain1.Anchored = false
Chain2.Anchored = false
end
end
