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

Will this script work in Studio's Test-Play feature?

Asked by 4 years ago
Edited 4 years ago

I'm new to Lua, this is my first script:

local Close = script.Parent.Parent.Parent.Parent.Close

local ClosingVAL = script.Parent.ClosingVAL

local ClosingVAL = Close.Disabled.False

If Closing=true then

wait (1) then script.Parent.Material = "Neon"

wait (1) then script.Parent.Material = "SmmothPlastic"

wait (1) then script.Parent.Material = "Neon"

wait (1) then script.Parent.Material = "SmmothPlastic"

wait (1) then script.Parent.Material = "Neon"

wait (1) then script.Parent.Material = "SmmothPlastic"

wait (1) then script.Parent.Material = "Neon"

wait (1) then script.Parent.Material = "SmmothPlastic"

end 

end

This is a regular scirpt, inside a Part. I didn't test this yet, but the expected outcome is for the parent of the script to change materials (and thus "blink") every one second. Should I make the wait time shorter? Will Studio even be able to recognize and successfully execute this script?

PS: ignore that 1| before the first end there, I have no idea how to get rid of it.

Like this, Geobloxia?

[(https://drive.google.com/file/d/1Goww0BE4GW1b7IzKJyv2Ux7EMLg9prVn/view?usp=sharing)]

0
You should use the code block to properly format that code instead of using it as a text. Also the material name is SmoothPlastic, not SmmothPlastic, may be a typo. AlmostADemon 50 — 4y
0
Like this, Geobloxia? theking10481 2 — 4y
0
Copy and paste the link into your browser. theking10481 2 — 4y

1 answer

Log in to vote
0
Answered by
Geobloxia 251 Moderation Voter
4 years ago
Edited 4 years ago

It will not work because for some reasons. Also, I didn't see the variable "Closing" to be defined in this script. That is also another reason. You have to define it. 1st reason: script.Parent.Material = SmoothPlastic will not work. You have to use enum:

script.Parent.Material = Enum.Material.SmoothPlastic
-- enumeration, is sometimes shortened to enum

2nd reason: You do not do wait(1) then. Do this:

wait(1) -- waits before proceeding to next line
script.Parent.Material = Enum.Material.SmoothPlastic

If you want it to keep repeating while Closing is true, use a while loop like this:

while closing == true do
    wait (1)  
    -- don't add a "then" after waits.
    script.Parent.Material = "Neon"
    wait (1)  
    script.Parent.Material = "SmoothPlastic"
    wait (1) 
    script.Parent.Material = "Neon"
    wait (1)  
    script.Parent.Material = "SmoothPlastic"
    wait (1) 
    script.Parent.Material = "Neon"
    wait (1)  
    script.Parent.Material = "SmoothPlastic"
    wait (1)  
    script.Parent.Material = "Neon"
    wait (1)  
    script.Parent.Material = "SmoothPlastic"
end
-- make sure you add a wait cooldown for while loops,
-- so they don't crash

For more information: https://developer.roblox.com/en-us/api-reference/property/BasePart/Material For material https://developer.roblox.com/en-us/articles/Loops/index.html For while loops and other loops.

0
What do yu mean by a "wait cooldown?" theking10481 2 — 4y
0
Like wait(2) or wait(5) or wait(1) or wait(time) (define variable first) Just some time (could be short or long) before the loop repeats Geobloxia 251 — 4y
0
So like "local ClosingVAL = script.Parent.ClosingVAL wait(1)?" theking10481 2 — 4y
0
What I mean is instead of doing while true do print("this will crash") end you do while true do wait(0.1) print("This won't") end Geobloxia 251 — 4y
Ad

Answer this question