For some reason, this tween won’t work on a LocalScript but works whenever it is in a normal Script. I am just trying to animate water here and it is confusing me as to why it won’t work on the Client.
local tweenService = game:GetService("TweenService")
local object = script.Parent
local TextureSpeed = 20
local tweenInfo = TweenInfo.new(
TextureSpeed,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
-1,
false,
0
)
for _, texture in pairs(object:GetChildren()) do
if texture:IsA("Texture") then
local textureTween = tweenService:Create(texture, tweenInfo, {OffsetStudsU = 100})
local textureTween2 = tweenService:Create(texture, tweenInfo, {OffsetStudsV = 100})
textureTween:Play()
textureTween2:Play()
end
end
To my knowledge, Local Scripts will only run under the Workspace if they are a descendant of a character. This means that unless they are a descendant of a character that is physically attached to an existing player in the game the local script wont run.
Local scripts do not work unless they are parented to a player. You will have to clone the local script to the player which has an array of all the predefined parts that need to be animated.
local tweenService = game:GetService("TweenService")
local objectTable = {game.Workspace:FindFirstChild("Part")} -- make this a list of all the parts that need to be animated
local TextureSpeed = 20
local tweenInfo = TweenInfo.new(
TextureSpeed,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
-1,
false,
0
)
for _, objects in pairs(objectTable) do
for _, texture in pairs(objects:GetChildren()) do
if texture:IsA("Texture") then
local textureTween = tweenService:Create(texture, tweenInfo, {OffsetStudsU = 100})
local textureTween2 = tweenService:Create(texture, tweenInfo, {OffsetStudsV = 100})
textureTween:Play()
textureTween2:Play()
end
end
end