This is not an issue. Roblox handles these numbers for you.
local part = Instance.new('Part')
part.Transparency = 1
print(part.Transparency == 1) -- true
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
His goal is to make a fading transition (TweenService has already been suggested)
I see where you’re coming from now. That is a very serious issue that should not happen.
Thanks all for the help! Ory eventually helped me troubleshoot the end part. All good, and I learned quite a lot.
Use TweenService instead.
local TweenService = game:GetService("TweenService")
local Boulder = script.Parent
local Info = TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut,0,false,0)
while true do -- Infinite loop (unless someone spills coffe on the server your game is running on)
task.wait(0.3) -- Waits before restarting again
local Tween = TweenService:Create(Boulder,Info,{Transparency = 1})
Tween:Play() -- Plays the tween which smoothly modifies transparency
Tween.Completed:Wait() -- Waits until the tween is finished
Boulder.Transparency = 0 -- Resets the transparency
task.wait(1) -- Waits before continuing loop again
end
Obviously you can tweak the wait times to give it the effect that you want. If this isn’t what you’re looking for, let me know.
Oh lol, Im not very good with Luau maths
Agreed, definitely learn TweenService. You won’t regret it!
The for loops are a hacky way to do this kind of thing which isn’t as smooth, and its harder to figure out how long you have to make the wait time in order for it to fit into a specified amount of seconds. TweenService
does this all for you. Definitely learn to use it.