I’ve been facing a persistent issue when animating Texture instances using OffsetStudsU and OffsetStudsV. Regardless of the method I use, TweenService, RunService with Heartbeat, RenderStepped, or Stepped, the FPS drops heavily as soon as the animation begins.
The lag happens even with just one animated texture, and it gets worse when more textures are added, such as when weapons are attached to player characters. All textures are optimized and compressed, so the problem doesn’t seem related to resolution.
I’ve also tested animating textures both on the client and server sides. Neither solved the performance issue.
I noticed that games like Bad Business use animated weapon skins and don’t seem to suffer from this problem. I’d really like to understand how they manage to keep performance stable with similar animations. Any insights or alternative methods would be greatly appreciated…
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(250, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1, false, 0)
for _, texture in script.Parent:GetDescendants() do
if texture:IsA("Texture") then
TweenService:Create(texture, tweenInfo, {OffsetStudsU = 50}):Play()
TweenService:Create(texture, tweenInfo, {OffsetStudsV = 50}):Play()
end
end
Right now what it’s doing is it is manually searching through your script.Parent textures every single time this is ran which is painfully slow. Use GetDescendants/GetChildren only when you can’t cache them in memory and if it’s only during runtime.
The solution is to put them into an array:
local textures = {}
-- Put them all into an array
for _, texture in script.Parent:GetDescendants() do
if texture:IsA("Texture") then
textures[#textures+1] = texture;
end
end
-- Now you can tween them faster
for _, texture in pairs(textures) do
TweenService:Create(texture, tweenInfo, {OffsetStudsU = 50}):Play()
TweenService:Create(texture, tweenInfo, {OffsetStudsV = 50}):Play()
end
Thanks for the tip! I’m already caching the textures, the issue seems to be with OffsetStudsU/V itself. It causes lag even with a few textures. I’m not sure if there’s any alternative way to animate textures without using it.
If you applied the script I gave you then the problem is most likely elsewhere.
Just to be clear is this script only played once or is it being run every frame? Also, are there more tweens/scripts other than this that’s playing?
Right now looking at the code it should not be lagging the game at all even if you have 100+ textures being tweened. Even at 1000 tweens playing all at once it should still be fine.
The tweens are only started once, nothing is running every frame. What’s strange is that the FPS drop only happens when the models with animated textures are attached to any character. In the video I shared, the first case (with character) causes a huge FPS drop, while the second case (with models unparented) runs smoothly, even with many textures. Video Hereee
The bug report mentioned a workaround where he welded the model to the character and placing it in Workspace. @6eerz Maybe you could try this? Though it would require you to get the position of the model correctly again. And seeing as how this post is over 4 years old now I’m not sure if there will be a fix for this bug.
Thanks to your response, I realized the issue wasn’t with the texture animation itself, but with the models being parented to the character. That was invalidating the fast clusters and causing the FPS spikes.
The solution was to move the animated models (like weapons and attachments) outside of the character and link them logically using their name or some other identifier. The texture animations still work perfectly, and performance is now stable. Really appreciate you pointing me in the right direction!
I managed to fix the issue based on that idea, and it was actually simpler than I expected. As soon as I realized the lag was coming from how the models were parented to the character, I moved them to Workspace and kept the behavior using Motor6Ds as usual. Nothing broke in my system, it was a smooth change.
It’s wild how such a small detail can cause massive performance drops, and yet there’s still no official fix. I really hope Roblox addresses this natively someday, because it directly affects games with customized characters or animated visuals.
Thanks a lot for sticking around from the start, your support really helped!