Tutorial for Scripting (function,loop)

Hi today I am Gonna Teach you How to make a Simple timer Portal or Door
NOTE: This is for Beginners

First Select a Part and add a Script to it

And Go to the Script Delete everything in it and start scripting

Create a variable for the Part and GO function

    local part = script.Parent

        local function go()
             part.Transparency = 0.3
            part.CanCollide = false
        end 

Now Lets add stop function

    local part = script.Parent

        local function go()
             part.Transparency = 0.3
            part.CanCollide = false
        end 
local function stop()
   part.Transparency = 0
    part.CanCollid = true
end 

lets call the function and make it run forever

    local part = script.Parent

        local function go()
             part.Transparency = 0.3
            part.CanCollide = false
        end 
local function stop()
   part.Transparency = 0
    part.CanCollide = true
end 

    while true do
       go() --open
       wait(3) --seconds
       stop()--close
        wait(3)
end

and save it and play in your game and check if it works

if you have any doubt let me know for example if don’t know what is function i will explain it to you and lets hope for 10 likes

5 Likes

CanCollid is not a property of BasePart. Please change it to CanCollide.

1 Like

While is undefined. Switch it to while as that is the correct word. Capitalisation matters in programming.
Also, please fix the indenting. It makes the code harder to read.

1 Like

Sorry I forgot to Copy paste from the roblox studio so i had to write it by myself