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

Need help with this script? [SOLVED]

Asked by
steev 0
10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

Im trying to make the part vanish and have NoCollide and then reappear with CanCollide

function bananaz ()
    h = 0
    repeat 
    game.workspace.part.transparency = (h) + 0.2
    wait (1)
    until game.workspace.part.transparency == 1


    repeat
    game.workspace.part.transparency = (h) - 0.2
    wait (1)
    until game.workspace.part.transparency == 0
    game.workspace.part.cancollide = false

game.Workspace.Part.Touched:connect(bananaz)

Any help?

3 answers

Log in to vote
0
Answered by 10 years ago
local t = 1 -- How much time the transition takes
local intervals = 50 -- How smooth the transition is
local busy = false
script.Parent.Touched:connect(function()
    if not busy then
        busy = true
        for i  = 0, 1, 1/intervals do
            script.Parent.Transparency = i
            wait(t/intervals)
        end
        script.Parent.CanCollide = false
        for i  = 1, 0, -1/intervals do
            script.Parent.Transparency = i
            wait(t/intervals)
        end
        script.Parent.CanCollide = true 
        busy = false    
    end
end)

This works, tested it myself.

EDIT: Replaced "workspace.part" with "script.Parent". If you put the script in the brick it should work.

0
Does this work for anchored bricks? steev 0 — 10y
0
Also just a normal script or a LocalScript? steev 0 — 10y
0
Works for anchored bricks and you should use this with a normal script PlaneFreak 0 — 10y
0
I just don't get it... when i touch the brick with the script in it, nothing happens it doesn't fade and it doesn't go NoCollide it just stays CanCollide :C steev 0 — 10y
0
Updated answer. PlaneFreak 0 — 10y
Ad
Log in to vote
0
Answered by 10 years ago
function bananaz ()
    h = 0
    repeat
    game.workspace.part.transparency = (h) + 0.2
    wait (1)
    game.workspace.part.cancollide = false
    until game.workspace.part.transparency == 1

    repeat
    game.workspace.part.transparency = (h) - 0.2
    wait (1)
    until game.workspace.part.transparency == 0
    game.workspace.part.cancollide = true


game.Workspace.Part.Touched:connect(bananaz)

maybe this will work

0
This one doesn't work :C steev 0 — 10y
Log in to vote
0
Answered by 10 years ago

Im not sure if this is right but you could try and do

function bananaz()
game.workspace.part.Transparency = 0
for i = 1,50 do
game.workspace.part.Transparency = game.workspace.part.Transparency  + 0.2
game.workspace.part.CanCollide = false
wait(1)
end

for i = 1,50 do
game.workspace.part.Transparency = game.workspace.part.Transparency  - 0.2
game.workspace.part.CanCollide = true
end

game.Workspace.part.Touched:connect(bananaz)

I Think that should work :P

0
I edited it try now pikamew9998 0 — 10y
0
Still doesn't work. You could either send me a whole new script or just leave it. Your choice. steev 0 — 10y
0
have you checked the output? pikamew9998 0 — 10y
0
What's the "output"? steev 0 — 10y

Answer this question