Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Changing the Transparency of a Model?

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?

1 comment

0

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

1 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.

3 comments

0

I am not certain if this is what you wanted, please comment if not.

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.