I’m currently trying to make a new game, I’m familiar with Lua and I can understand the language, but sadly I cannot script anything yet. I’ve tried searching for the script I need on social media but still haven’t found it, that’s why I’m asking you.
It is a short script so it should be fine.
I’m searching for a for a script that makes 2 parts work like this: A blue block stays visible for 3 seconds, you also can jump and stand on it, the usual. But after those 3 seconds, the blue part disappears and a red part appears for 3 seconds. You can stand on it again, and after the time’s up, it changes to the blue part again, a loop.
local function setVisible(part, isVisible)
part.Transparency = isVisible and 0 or 1
part.CanCollide = isVisible
end
while true do
setVisible(part2, false)
setVisible(part1, true)
wait(3)
setVisible(part1, false)
setVisible(part2, true)
wait(3)
end
Transparency and CanCollide, if you want multiple parts to be set visible
local RedPartFolder = workspace["RedPartFolder"]
local BluePartFolder = workspace["BluePartFolder"]
local Toggle = false
local function setVisible(part, isVisible)
part.Transparency = isVisible and 0 or 1
part.CanCollide = isVisible
end
while wait(3) do
if Toggle then
Toggle = false
else
Toggle = true
end
for i, part in pairs(RedPartFolder:GetChildren()) do
setVisible(part, Toggle)
end
for i, part in pairs(BluePartFolder:GetChildren()) do
setVisible(part, not Toggle)
end
end
@Dandystan Oh yeah. Sorry, my bad. @Crashstyler747 Here is a Script to do it:
local RedParts = {}
local BlueParts = {}
local Showed = "Red"
for _, v in pairs(game.Workspace.Parts:GetChildren()) do
if v.Name == "Red" then
table.insert(RedParts,v)
elseif
v.Name == "Blue" then
table.insert(BlueParts,v)
end
end
function ToggleParts()
if Showed == "Red" then
for _, v in pairs(RedParts) do
v.Transparency = 1
v.CanCollide = false
end
for _, v in pairs(BlueParts) do
v.Transparency = 0
v.CanCollide = true
end
Showed = "Blue"
elseif
Showed == "Blue" then
for _,v in pairs(RedParts) do
v.Transparency = 0
v.CanCollide = true
end
for _, v in pairs(BlueParts) do
v.Transparency = 1
v.CanCollide = false
end
Showed = "Red"
end
end
while true do
wait(0.5)
ToggleParts()
wait(0.5)
end
Showed is a variable that tells us which Parts are currently showed. Everytime you run the Function ToggleParts() the Red parts will disappear and there will appear the Blue parts.
Insert into a Folder, in Workspace, called “Parts” as many Parts as you want. Just make sure that the Red Parts are called “Red” and the Blue ones are called “Blue”.
Or you could use my solution by using folders. Parent the parts to their respective color folder, RedPartFolder and BluePartFolder are folders containing parts.
To be honest, using folders is better than naming each part if you’re lazy.
Scripting Support is not a venue to ask for code. Please do not make such threads in the future. See the category guidelines for information on the category.