Arithmetics with variables

Hello. Im trying to make a ball fade out, with a variable that gets +ed by 0.1 that i put the transparency to. I use a loop that +es the variable by 0.1 until its at 1. CODE:


local effect = Instance.new("Part", workspace)
effect.PartType = Ball
effect.Size = Vector3.new(100, 100, 100)
local countdown = 0
while countdown > 1 do
countdown + 0.1 effect.Transparency = countdown end

i’m assuming when you say “+ed” and “+es” (“plused” & “pluses”) you mean added and adds

while countdown > 1 do  
  countdown = countdown + 0.1 -- 'countdown += 0.1' also works
  effect.Transparency = countdown
  wait() -- yield
end

i’d suggest you try using TweenService

local TweenService = game:GetService("TweenService")
local tInfo = TweenInfo.new()

local Effect = Instance.new("Part", workspace)
Effect.PartType = Ball
Effect.Size = Vector3.new(100, 100, 100)
TweenService:Create(Effect, tInfo, {["Transparency"] = 1}):Play() -- Tween the transparency
1 Like