I'm trying to create a script that upon the explosion hitting a SEPARATE brick, an entire model would go from being transparent and CanCollide = false to opaque and CanCollide = true. Here's my current code:
local explosive = game.Workspace.explosive local rigged = false function unScrambleAtoms() ladder = game.Workspace.ladder ladder.Transparency = 0 ladder.CanCollide = true end function explosionAct() if rigged == false then rigged = true wait(5) local explosion = Instance.new("Explosion") explosion.Parent = script.Parent explosion.Hit:connect(unScrambleAtoms()) end end while rigged == false do explosionAct() wait() end
It seemed correct in my head... (I thought of it when I was at school then wrote it down)
Any help?
local explosive = game.Workspace.explosive local rigged = false function unScrambleAtoms() ladder = game.Workspace.ladder for i, v in pairs(ladder:GetChildren()) do --Loop through each object in the ladder model. v.Transparency = 0 v.CanCollide = true end end function explosionAct() rigged = true wait(5) local explosion = Instance.new("Explosion") explosion.Parent = script.Parent explosion.Hit:connect(unScrambleAtoms()) end while true do --I don't know why this is needed, because you never set rigged back to false. if not rigged then explosionAct() end wait() end
This script makes the "ladder" model invisible when the explosion hits any part.