A bunch of people have been bombarding me with this exact question recently to my messages, so I will answer this question. I don’t get why people want to know how to do this but I’m willing to help anyway. First get your wall part ready, then add a script to it.
local wall = script.Parent -- tells the script the the wall is it's parent
local function hide() -- creating a function to hide the wall
wall.Transparency = 1 -- Makes the wall transparent
wall.CanCollide = false -- Makes the wall penetrable
end
local function show() -- creating a function to show the wall
wall.Transparency = 0 -- Makes the wall opaque
wall.CanCollide = true -- Makes sure that nothing can go through the wall
end
while true do -- Making the action loop over and over again
wait(1) -- add a wait function in (Studio will crash if you don't)
hide() -- This function will hide the wall
wait(1)
show() -- This function will show the wall
end
This can literally be found on the developer hub. Developer Hub Why are people messaging me about this?!
This is actually super inefficient. The answer below is much better.
local wall = script.Parent
while true do
task.wait(1)
wall.Transparency = (wall.Transparency == 1 and 0 or 1)
wall.CanCollide = not wall.CanCollide
end
This script very easy, but good for beginners. Next time try to do the same but with tween service, like it’s going underground and back to normal repeatedly.
Yes, inefficient. There are two functions that control the on and off state. That’s a waste of memory. In addition, the deprecated wait should be replaced with task.wait.
Woah. I wouldn’t even write that, make it simpler for begginners.
while true do
if Part.Transparency == 1 then
Part.Transparency = 0
else
Part.Transparency = 1
end
if Part.CanCollde == false then
Part.CanCollide = true
else
Part.CanCollide = false
end
end
--
Ik it's longer, but easier to understand
OP’s post isn’t super inefficient. It does what it needs to do with acceptable efficiency.
The one grievance I have with your code is that it’s not easily readable. I’ve been programming for a decade, and I’m not in the habit of using hacky and-or statements, so I have to take another glimpse every time I read that. I’m pretty sure they added this syntax just for simpletons like me:
local FlashyWalls = game:GetService("CollectionService"):GetTagged("FlashyWall")
while true do
for i,v in ipairs(FlashyWalls) do
task.wait(1)
wall.CanCollide = not wall.CanCollide
wall.Transparency = if wall.CanCollide then 0 else 1
end
end