hey guys, recently I made this beam ring that’s supposed to look like TSB’s one.
here is a video comparing the two, and I think it looks pretty similar:
for my code tho, is there any improvements I can make?
somebody told me that my code assumes that each frame doesn’t lag, and if one frame does, it will delay the rest of the frames
I would also like to be able to adjust the speed at which the ring tweens!
--Parts
local part = script.Parent
local att0 = part.Attachment0
local att1 = part.Attachment1
local beam0 = part.Beam0
local beam1 = part.Beam1
local startVal = 0
local endVal = 1
local stepVal = 0.01
local interval = 0.01
task.wait(3)
for i = startVal, endVal + stepVal, stepVal do
local value = math.round(i * 100) / 100
local curveSize = (value * 4) / 3
local width = 0.5 - (0.45 * value)
att0.CFrame = CFrame.new(Vector3.new(0, 0, value))
att1.CFrame = CFrame.new(Vector3.new(0, 0, -value))
beam0.Transparency = NumberSequence.new(value)
beam0.CurveSize0 = curveSize
beam0.CurveSize1 = -curveSize
beam0.Width0 = width
beam0.Width1 = width
beam1.Transparency = NumberSequence.new(value)
beam1.CurveSize0 = -curveSize
beam1.CurveSize1 = curveSize
beam1.Width0 = width
beam1.Width1 = width
print(value)
task.wait(interval)
end
thanks in advance! 
2 Likes
You should probably consider with task.wait()
Overall, you’re doing good!
what should I replace it with tho?
sorry for not having attention
I just watched the video recently, you should keep it the same
Don’t mind too much about me 
why are you not using TweenService for this?
here’s a recoded version, I think it’s pretty clean
local tweenService = game:GetService("TweenService")
local part = script.Parent
local att0 = part.Attachment0
local att1 = part.Attachment1
local beam0 = part.Beam0
local beam1 = part.Beam1
--TweenInfo
local default = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
local numberValue = Instance.new("NumberValue") --For transparency
--Ring properties
local radius = 3
local curveSize = radius * (4/3)
local startWidth = 1
local endWidth = 0.2
local properties = {
["Attachment0"] = {
["CFrame"] = CFrame.new(Vector3.new(0, 0, radius))
},
["Attachment1"] = {
["CFrame"] = CFrame.new(Vector3.new(0, 0, -radius))
},
["Beam0"] = {
["CurveSize0"] = curveSize,
["CurveSize1"] = -curveSize,
["Width0"] = endWidth,
["Width1"] = endWidth
},
["Beam1"] = {
["CurveSize0"] = -curveSize,
["CurveSize1"] = curveSize,
["Width0"] = endWidth,
["Width1"] = endWidth
},
["NumberValue"] = {
["Value"] = 1
}
}
--Preset values
numberValue.Value = 0
beam0.Width0 = startWidth
beam0.Width1 = startWidth
beam1.Width0 = startWidth
beam1.Width1 = startWidth
task.wait(3)
for i, v in part:GetChildren() do
if properties[v.Name] then
local tween = tweenService:Create(v, default, properties[v.Name])
tween:Play()
end
end
numberValue:GetPropertyChangedSignal("Value"):Connect(function()
beam0.Transparency = NumberSequence.new(numberValue.Value)
beam1.Transparency = NumberSequence.new(numberValue.Value)
end)
local transparencyTween = tweenService:Create(numberValue, default, properties["NumberValue"])
transparencyTween:Play()
transparencyTween.Completed:Wait()
numberValue:Destroy()
1 Like