Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Changing the Transparency of a Model?

Asked by
OniiCh_n 410 Moderation Voter
10 years ago

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?

0
I am so confused as to what this does. The while rigged == false do is pointless, and why is the function named unScrambleAtoms...? PiggyJingles 358 — 10y

1 answer

Log in to vote
1
Answered by 10 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.
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.

0
I am not certain if this is what you wanted, please comment if not. Articulating 1335 — 10y
0
I myself don't know why I put the while loop in... It seems to be correct... I'll have to test it when I get home OniiCh_n 410 — 10y
0
I myself don't know why I put the while loop in... It seems to be correct... I'll have to test it when I get home OniiCh_n 410 — 10y
Ad

Answer this question