Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)]

3 comments

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.

0

Like this, Geobloxia?

0

Copy and paste the link into your browser.

1 answer

✓ Accepted answer

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.

4 comments

0

What do yu mean by a "wait cooldown?"

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

0

So like "local ClosingVAL = script.Parent.ClosingVAL wait(1)?"

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

This discussion is preserved as it was. New answers, comments, and votes are closed.