I’m trying to make a script that animates bunch of decals without much lag, it only works for a single one but not many, i do not know how would I accomplish this.
I’ve tried using tables but that did not work. I am very disappointed that roblox would make something so simple into something so complicated.
NOTE: THERE ARE REAL ID NUMBERS; i just do not feel like sharing my images.
local textures = script.parent:GetDescendants()
while true do
textures.Texture = "http://www.roblox.com/asset/?id=[id numbers]"
wait(math.random(1,30))
textures.Texture = "http://www.roblox.com/asset/?id=[id numbers]"
wait(0.1)
textures.Texture = "http://www.roblox.com/asset/?id=[id numbers]"
wait(0.1)
textures.Texture = "http://www.roblox.com/asset/?id=[id numbers]"
wait(0.8)
textures.Texture = "http://www.roblox.com/asset/?id=[id numbers]"
wait(0.1)
textures.Texture = "http://www.roblox.com/asset/?id=[id numbers]"
wait(0.1)
end
the script returns no errors and the script seems to run, but no textures get changed.
this is how the folder is laid out; folder > script/ 2 parts > each part has one decal inside.
Tables are simple, youre just using them incorrectly.
In this line, textures looks like this: {Texture1, Texture2, Texture3}, and the .Texture property doesnt exist, as youre trying to set the Texture of a table, which is impossible, or youre just going to set the first image in the table to the texture you desire.
This code should work:
-- If your texture is in a single part, just use Part:GetChildren(), its less laggy than Part:GetDescendants()
local textures = script.parent:GetDescendants()
-- Using a function to cut down on lines, and make it easier to modify.
function UpdateImages(TextureId)
for i, v in pairs(textures) do
if v:IsA("Texture") then
v.Texture = "rbxassetid://"..TextureId
end
end
end
while task.wait(0.1) do
UpdateImages("Texture ID")
task.wait(math.random(1, 30))
UpdateImages("Texture ID")
task.wait(0.1)
UpdateImages("Texture ID")
task.wait(0.1)
UpdateImages("Texture ID")
task.wait(0.8)
UpdateImages("Texture ID")
task.wait(0.1)
UpdateImages("Texture ID")
end