Can someone help me? I don’t know what’s wrong with my game. Maybe it’s a script. Here’s it anyway
local tweenService = game:GetService("TweenService")
local baseplate = workspace.Water
function move()
for i,v in baseplate:GetDescendants() do
if v:IsA("BasePart") then
local startPosition = v.Position
v.Position = startPosition
local tween = tweenService:Create(v, TweenInfo.new(24, Enum.EasingStyle.Linear), {Position = Vector3.new(0,-9,v.Size.Z/10 - 10)})
tween.Completed:Connect(move)
tween:Play()
end
end
end
move()
Your script is recursively calling move() every time a tween completes, creating an infinite loop that spawns more and more tweens, eventually overwhelming your computer.
You can cut the loop workload down here quite a bit also.
local tweenService = game:GetService("TweenService")
local baseplate = workspace.Water
local tweens = {}
for _, v in baseplate:GetDescendants() do
if v:IsA("BasePart") then
tweens[v] = tweenService:Create(v, TweenInfo.new(24, Enum.EasingStyle.Linear),
{Position = v.Position + Vector3.new(0, -9, 0)})
end
end
while true do
for _, tween in pairs(tweens) do
tween:Play()
end task.wait(24)
end
Unless you’re deleting parts of that water this should work fine.
This is the main problem (logic error): tween.Completed:Connect(move)
If this isn’t looping the tweens right try this:
possible resetting
local tweenService = game:GetService("TweenService")
local baseplate = workspace.Water
local tweens = {}
for _, v in baseplate:GetDescendants() do
if v:IsA("BasePart") then
local startPos = v.Position
tweens[v] = {tween = tweenService:Create(v, TweenInfo.new(24, Enum.EasingStyle.Linear),
{Position = v.Position + Vector3.new(0, -9, 0)}), startPos = startPos}
end
end
while true do
for v, data in pairs(tweens) do
v.Position = data.startPos
data.tween:Play()
end task.wait(24)
end