So I’m trying to make a shockwave effect by cloning a sphere into workspace and dissapears while gradually increasing its size and transparency so if the sphere’s parent is workspace then it will fade dissapearing into oblivion, I use two ways and that is tweening the size,transparency or for looping increasing the size and transparency and also how do determine which consumes memory more in studio?
For loop
local swave = game:GetService("ServerStorage").Sphere
if swave.Parent == workspace then
for p = 20,200,5 do
swave.Size = Vector3.new(p,p,p)
wait(.2)
end
for p = 0,1,.1 do
swave.Transparency = p
wait(.2)
end
swave:Destroy()
end
Tween animation:
local ts = game:GetService("TweenService")
local ta = Tweeninfo.new(1,"Linear")
local s = 200
if swave.Parent == workspace then
local t = ts:Create(swave,ta,{Size = Vector3.new(s,s,s); Transparency = 1})
t:Play()
t.Completed:Wait()
swave:Destroy()
end
This really depends on the situation, but using a for loop is more raw, and would use slightly less processing power in some simple cases, only because it doesn’t have the extra options to configure.
TweenService does provide simple options for making more aesthetic tweens, such as EasingStyles though.
I honestly don’t think this is something that needs to be worried about, as the amount of power each uses is very slim if it differs at all. Just use whichever is more practical and convenient. They really both work on the same principles of Lerping regardless, so it shouldn’t make much of a difference performance wise.
Neither if ran on the server, both stutter and the server doesn’t run on the same power that a client’s machine does. Tween if ran on the client, solely because your for loop uses wait. Neither if both of them were using lerp and the for loop with lerping ran based on RunService.Heartbeat frequency.
TweenService was mostly created to resolve the issue of needing to manually write out translations for models the way you did it in the OP with the for loop. The engine will interpolate towards the goal with the given information you pass it (TweenInfo and Goals dictionary).
I personally prefer tweens because there are a lot of built in styles for animating, with a for loop you will have to write your own equations for animating.
Yes, you can check script performance, how much activity is going on with the performance button under view tab. Script performance can be varying because of the loops and how fast the loops iterate. I have read that it normally is under 2-3%. But I think it also depends on the client’s machine.