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

Why does my if true then statement only work once?


part1 = game.Workspace.Part

if true then
	part1.Transparency = 0
	wait(2)
	part1.Transparency = 1
end

Errors: No errors

Prob something simple but just curious on why it only works once as this happened to me a couple times before.

2 comments

0

If statements only work once, a simple loop could resolve your answer

0

you can try while true do

1 answer

✓ Accepted answer

An if statement will only ever happen once unless told otherwise, for this you will need to use a loop, for example if you were to use a while true do loop like this:

while true do
wait(1) -- wait 1 sec
part1 = game.Workspace.Part

if true then
    part1.Transparency = 0
    wait(2)
    part1.Transparency = 1
end
end

Then that would repeat every second, a wait is ALWAYS required with a while true do loop as otherwise your game will simply crash.

ACCEPT THIS IF IT HELPED!

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