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

Why isin't this set transparency brick working?

Asked by 4 years ago

~~~~~~~~~~~~~~~~~

local Part = script.Parent

local EndParts = {game.Workspace.TEndPart, game.Workspace.DEndPart, game.Workspace.Neon1EndPart, game.Workspace.DessertEndPart, game.Workspace.ASHEndPart}

Part.Touched:Connect(function() for _, object in pairs (EndParts) do object.Transparency = 1 object.CanCollide = false wait(60) object.Transparency = 0 object.CanCollide = true end end) ~~~~~~~~~~~~~~~~~~

I'm confused to why it's not working at all, help would be appreciated

0
Is the Part anchored? Block_manvn 395 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

Hello. The problem is that you have a wait(60) in the loop meaning it'll have to wait one minute before going on to the next part, meaning that it would take five minutes for the part to turn invisible. Instead, make a separate loop that makes the EndParts visible again with a wait in between the two loops. Try this:

local Part = script.Parent

local EndParts = {game.Workspace.TEndPart, game.Workspace.DEndPart, game.Workspace.Neon1EndPart, game.Workspace.DessertEndPart, game.Workspace.ASHEndPart}

Part.Touched:Connect(function() 
    for _, object in pairs(EndParts) do 
        object.Transparency = 1 
        object.CanCollide = false 
    end 

    wait(60)

    for _, object in pairs(EndParts) do 
        object.Transparency = 0
        object.CanCollide = true
    end 
end) 

If you want it to happen when a humanoid/player touches it, do this:

local Part = script.Parent

local EndParts = {game.Workspace.TEndPart, game.Workspace.DEndPart, game.Workspace.Neon1EndPart, game.Workspace.DessertEndPart, game.Workspace.ASHEndPart}

Part.Touched:Connect(function(otherPart) 
    if otherPart.Parent:FindFirstChildOfClass("Humanoid") then
        for _, object in pairs(EndParts) do 
            object.Transparency = 1 
            object.CanCollide = false 
        end 

        wait(60)

        for _, object in pairs(EndParts) do 
            object.Transparency = 0
            object.CanCollide = true
        end 
    end
end) 

When the part is touches, it'll check for a humanoid. If it has one, it'll continue the script.

Please accept and upvote this answer if it helped you.

Ad
Log in to vote
0
Answered by 4 years ago

I'm guessing u want it to be on touched, so it would be

Part.Touched:Connect(function(touched)

I'm not sure if it works but give it a go and see what happens, if it not works then i wish u a good day and good luck.

0
You don't need a touched parameter for the touched event as it will still work. youtubemasterWOW 2741 — 4y
0
ty for telling me, i just learned this stuff so sometimes i get something wrong DFROBUXX 28 — 4y
0
np youtubemasterWOW 2741 — 4y

Answer this question