I have a walking animation for one of my characters. I imported the seperate decals onto a string where it will load it using string.sub. It only loads one decal per second tho. Is there a way to make it load the string values faster?
local animate = {"rbxassetid://11469164411", "rbxassetid://11469163009", "rbxassetid://11469165118", "rbxassetid://11469163009"}
while true do
for i, v in pairs(animate) do
for i = 1, string.len(v) do
wait()
script.Parent.Image = string.sub(v, 1)
end
end
end
my only workaround so far is this ugly block of code.
while true do
wait(0.25)
script.Parent.Image = "rbxassetid://11469164411"
wait(0.25)
script.Parent.Image = "rbxassetid://11469163009"
wait(0.25)
script.Parent.Image = "rbxassetid://11469165118"
wait(0.25)
script.Parent.Image = "rbxassetid://11469163009"
end
Yes, I know it says “While true do.” It’s just so I can see how it runs on studio first before implementing it to my script.
wait() usually only waits ~1/30 of a second and your IDs have around 25 characters, so looping through each string character-by-character will take a little under a second. I’m not sure if I understand your question completely, but couldn’t you loop through the animate array and set the Image to the value of each iteration?
while true do
for i, v in pairs(animate) do
script.Parent.Image = v
task.wait()
end
end
Ah, no worries Basically instead of doing all the string.sub and string.len stuff in the loop, just set script.Parent.Image to v instead.
local animate = {"rbxassetid://11469164411", "rbxassetid://11469163009", "rbxassetid://11469165118", "rbxassetid://11469163009"}
while true do
for i, v in pairs(animate) do
script.Parent.Image = v -- set .Image to v instead of string.sub(v,1)
task.wait(0.25) -- task.wait() is more accurate than wait()
end
end