Roblox studio crashes because of 4 meshes in a model

So, I redesigned the road to look like water. But the water was from a plugin. So this happened to my PC.


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()

Plugin used: Part to Water [ANIMATED]

You know that I’m still figuring out this

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

Or just fix the recursively calling move()

This worked finely without crashing. Was gonna use 2 separate scripts but you figured it out.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.