j8cksxn
(j8cksxn)
April 11, 2020, 5:30pm
#1
Hello!
I have been attempting to use the repeat-until
loop, however in this case it does not seem to stop the loop.
I have been playing around with the script for a while now, and I just need a fresh pair of eyes to tell me if there is something wrong.
I have tried using a while Transparency < 1 do
loop, as well as a numeric for
loop.
local block = script.Parent
repeat
block.Transparency = block.Transparency + 0.01
block.CanCollide = false
wait()
until block.Transparency == 1
wait(3)
block.Transparency = 0
block.CanCollide = true
EDIT: If I test it in studio the transparency of the block goes up past 1?
Not sure how or why.
ANOTHER EDIT: When I attempted the for loop before it didn’t work because I added an increment of 0.01.
2 Likes
sjr04
(uep)
April 11, 2020, 5:32pm
#2
Not sure why it won’t work, but for doing something a set amount of times, that is what a numeric for loop
is for see what i did there
for i = block.Transparency, 1, 0.01 do
block.Transparency = i
wait(0.1)
end
11 Likes
j8cksxn
(j8cksxn)
April 11, 2020, 5:33pm
#3
I have also tried that, it does not work.
j8cksxn
(j8cksxn)
April 11, 2020, 5:34pm
#4
However, I will try it once more, maybe I did something wrong.
xPuff_le
(LePoof)
April 11, 2020, 5:34pm
#5
Try this;
repeat wait() -- Wait up here.
-- Code here B)
until
4 Likes
j8cksxn
(j8cksxn)
April 11, 2020, 5:35pm
#6
Alright, I’ll try it, thank you.
sjr04
(uep)
April 11, 2020, 5:35pm
#7
That makes absolutely no difference.
3 Likes
Move
block.Transparency = 0
to before the loop. I think that maybe it starts with a transparency of 1 and therefore wouldn’t enter the loop.
1 Like
j8cksxn
(j8cksxn)
April 11, 2020, 5:38pm
#9
Did not work, no errors or anything.
Does it skip the loop completely or does it enter once?
(The repeat version)
1 Like
xPuff_le
(LePoof)
April 11, 2020, 5:38pm
#11
I read the question wrong… I thought the loop wasn’t working at all… Looking at it I don’t know what’s wrong, but maybe see if it’s in a client script (local) and if it isn’t is the transparency changing?
j8cksxn
(j8cksxn)
April 11, 2020, 5:39pm
#12
It is server sided, maybe my recent edit will spark an idea?
How do you call this code? Server-side scripts won’t run of themselves the same way scripts on the client will.
xPuff_le
(LePoof)
April 11, 2020, 5:40pm
#14
Maybe try doing;
until block.Transparency >= 1
That way if the transparency doesn’t add up to exactly 1, it will work if it’s higher.
j8cksxn
(j8cksxn)
April 11, 2020, 5:40pm
#15
It runs as soon as the script loads, I will implement it into a .Touched event afterwards.
A server script doesn’t run as soon as the script loads. You need to connect the code to something that will call it like a player joining, the server starting or a .Touched event as you said.
j8cksxn
(j8cksxn)
April 11, 2020, 5:43pm
#17
No, it seems to run fine, just the loop doesn’t stop.
1 Like
Have you checked so the value gets updated in every iteration?
j8cksxn
(j8cksxn)
April 11, 2020, 5:45pm
#19
Nope, but I found a solution already.
Thank you for the help anyways!
1 Like
What was the solution? just curious.