I am very weak at scripting and need some help with repeating this script.
wait(0.5)
game.Workspace.Part.Transparency = 1
wait(0.5)
game.Workspace.Part.Transparency = 0
I am very weak at scripting and need some help with repeating this script.
wait(0.5)
game.Workspace.Part.Transparency = 1
wait(0.5)
game.Workspace.Part.Transparency = 0
You could’ve researched before you made a post…
Anyways, there are many things called Loops that will reiterate something over and over. There are 3 loops: while, repeat and for.
while and repeat loops will run always as long as the condition you want is met, while for will just iterate a specific number of times, and even iterate through a whole table.
Infinite loops can be achieved using:
-- while loops continue to run as long as the condition evaluates to true
while true do
wait() -- without any yielding (waiting), the game will crash
end
OR
-- repeat loops will continue to run as the condition evaluates to false
repeat
wait() -- same reason as the wait in the while loop
until false
In your case, you’d do:
while true do
part.Transparency = 1
wait(.5)
part.Transparency = 0
wait(.5)
end
Or if you want to repeat it a specific amount of times, use a for loop:
-- structure: for [index] = [start], [end], [increment] do
for i = 1, 20 do
-- do stuff
end
Thanks Didn’t know people had tutorials online about this topic.
you can make
while true do
wait()
end
into just
while wait() do end
If there’s a way you can do something with events instead of wait(), use the event.
game:GetService("RunService").Heartbeat:Connect(function()
-- do stuff
end)
or
while (true) do
-- do stuff
game:GetService("RunService").Heartbeat:Wait()
end
i am confused, trying to do something similar and not really good at scripting just learning rn.
i made this and it is not working, any idea why?
while true do
script.Parent.Transparency=1
wait(1)
script.Parent.transparency=0
end
Edit:
while true do
script.Parent.Transparency = 1
wait(.5)
script.Parent.Transparency = 0
wait(.5)
end
how dose this work but the one i made dosent whats behind that?
the loop probably iterates too quickly for you to see it, try:
while true do
script.Parent.Transparency = 1
wait(1)
script.Parent.Transparency = 0
wait(1)
end