How about switch line 6 with line 5?
But its already at 0 transparency, so its redundant.
No, it will repeat everything between repeat
and until
UNTIL the stuff after until
is achieved.
Alright so I fixed the error, but now the boulder won’t go back to transparency 0. It stays at 1.
may we see the new script?
abcde
local ts = game:GetService("TweenService")
local boulder = script.Parent
local waitPeriod = 1 --Change this number to how long the fading transition should be in seconds.
local tween = ts:Create(boulder, TweenInfo.new(waitPeriod), {Transparency = 1})
while true do
tween:Play()
tween.Completed:Wait()
boulder.Transparency = 0
wait(1)
end
If you don’t understand anything in this script, tell me!
I edited the main post, and that contains the updated one.
A bit of a big issue, I have no idea what TweenService does or is. I could probably search it up real quick.
That won’t work as it would set the transparency to 0 after adding 0.1 and will keep the boulder at 0 transparency. Also transparency cannot go over 1 so using >
wont work either
I found your issue!
Here’s the short explanation: Instead of boulder.Transparency == 1
, use boulder.Transparency >= 1
Here’s the long explanation: Computers aren’t precise with decimal numbers. The game believed that the transparency wasn’t 1, but 1.00000000008592 or something along those lines. SInce that isn’t 1, it kept going.
You should still use TweenService over this though, it’s definitely a skill worth learning.
This is not an issue. Roblox handles these numbers for you.
local part = Instance.new('Part')
part.Transparency = 1
print(part.Transparency == 1) -- true
In the script he used, you can see he kept adding up decimal numbers. His issue was that the repeat until
loop never finished because the condition was never met.
If you are very confused on TweenService and want to stay with your original idea then use the following code
local boulder = script.Parent
while true do
boulder.Transparency = boulder.Transparency + 0.1
if boulder.Transparency >= 1 then
boulder.Transparency = 0
end
wait(1)
end
So, it looks like your method works in one way. But part of it is still broken.
Here is the current code.
I added can collide more as a quality of life feature, and that works now that I used >= operator. But it still doesn’t go back to transparency 0.
Where do you make Transparency
get set to 0?
This only happens with tiny ass numbers, not 0.1. Computers can handle that math.
e.g.
local part = Instance.new('Part')
for i = 0, 1, (0.005) do
part.Transparency = i
end
print(part.Transparency) -- 0.9950000047683716 😬
and
local part = Instance.new('Part')
for i = 0, 1, (0.1) do
part.Transparency = i
end
print(part.Transparency) -- 1
You are completely right, when I rewrote the code I must have forgot to add it back.
I believe you could just write
boulder.Transparency += 1
for simplicity