Hello! So I have this water texture animation, but I want it to run forever. However, if I use -1, it’ll reset back to its original pos. Please help!
local ts = game:GetService("TweenService")
local info = TweenInfo.new(8, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1)
local cs = game:GetService("CollectionService")
local rs = game:GetService("RunService")
for i, water in pairs(cs:GetTagged("Water")) do
local texture = water.Layer3.TextureTop
ts:Create(texture, info, {OffsetStudsV = 6}):Play()
end
How come? Would enclosing the entire for each loop in a while loop not work, since you would just be creating the tweens again every time and you could just task.wait the tweens time property.
thinking about it now, the best way is to increase the offset by an amount every frame.
local texture = script.Parent:WaitForChild("Texture")
game["Run Service"].Heartbeat:Connect(function(delta)
texture.OffsetStudsV += 5*delta
--multiply by delta to keep it consistent over any framerate
end)
If it’s a repeating texture, you could just wait for the tween to complete and set the offset back to zero, but runservice would probably be better in the case of it moving in the same direction infinitely.