Lots of lag when moving a detailed model

I have a big problem.

I have a detailed model im making a Titanic game. It wont sink correctly it lags up the whole game when I move it through a script heres an example of one my scripts

while true do
	Bow:PivotTo(Bow:GetPrimaryPartCFrame():Lerp((Bow:GetPrimaryPartCFrame() * CFrame.new(0,-0.015,0)),SinkingSpeedBeforeCrack))
	Bow:PivotTo(Bow:GetPrimaryPartCFrame():lerp((Bow:GetPrimaryPartCFrame() * CFrame.Angles(-0.0002,0,0)),SinkingSpeedBeforeCrack))
	Stern:PivotTo(Stern:GetPrimaryPartCFrame():lerp((Stern:GetPrimaryPartCFrame() * CFrame.new(0,-0.015,0)),SinkingSpeedBeforeCrack))
	Stern:PivotTo(Stern:GetPrimaryPartCFrame():lerp((Stern:GetPrimaryPartCFrame() * CFrame.Angles(-0.0002,0,0)),SinkingSpeedBeforeCrack))
	if Stern.MainBlockStern.Orientation.X == -5 or Stern.MainBlockStern.Orientation.X < -5 then

Please can anybody help me! Thank you.

1 Like

try moving everything else up instead if the water (and decorations) are smaller

also perhaps try to not move it every like frame, you could instead have it move like every half a second in slightly larger increments. Theres likely a combination of wait time and movement distance that would look similar to this but be less laggy.


Hello, I don’t know if this would help with the lag but it does swap the deprecated functions with the corresponding non-deprecated functions. If you have any question feel free to ask!

--|< Services >|--
local TweenService = game:GetService("TweenService");
local RunService = game:GetService("RunService");

--|< Configuration >|--
local sinkingSpeedBeforeCrack = 0.05;
local sinkingTime = 1; -- Tween Length

--|< Functions >|--
local function tweenCFrame(part, targetCFrame, time)
    local tweenInfo = TweenInfo.new(time, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut);
    local tween = TweenService:Create(part.PrimaryPart, tweenInfo, {CFrame = targetCFrame});

--|< Main >|--
while RunService.RenderStepped:Wait() do    
    local bowCFrame = Bow:GetPrimaryPartCFrame();
    local sternCFrame = Stern:GetPrimaryPartCFrame();
    local sinkMovement = CFrame.new(0, -0.015, 0);
    local tiltMovement = CFrame.Angles(-0.0002, 0, 0);
    local bowNewCFrame = bowCFrame * sinkMovement * tiltMovement;
    tweenCFrame(Bow, bowNewCFrame, sinkingSpeedBeforeCrack * sinkingTime);
    local sternNewCFrame = sternCFrame * sinkMovement * tiltMovement;
    tweenCFrame(Stern, sternNewCFrame, sinkingSpeedBeforeCrack * sinkingTime);
    if Stern.MainBlockStern.Orientation.X <= -5 then

if this still lags, you could try to replace the line while RunService.RenderStepped:Wait() do with while task.wait(0.25) do.

1 Like

Thank you I’ll try this real quick I’ll tell you once im done!

1 Like

I got an error “RenderStepped event can only be used from local scripts”

Alright, then remove the RunService Variable and replace the line while RunService.RenderStepped:Wait() do with while task.wait(0.25) do .

still really laggy i even turned it up to 1.25 so idk what to do tbh

Well, You could do what the other person suggested and try moving the environment instead of the boat.

are you able to move terrain water? I dont really like the idea

If your water is terrain-based, then there’s no need to move it as there’s already wind that can be easily modified (wind direction, strength, etc.), and it’ll just seem like the boat is moving due to the wind. Otherwise, if the water is a regular part, just move the water.

Changing the CFrame of large amounts of objects constantly is insanely laggy at a certain point, and I’d assume it would be done on the server, putting way too much load on it which will lag everyone due to slow server response times, even super high-end devices. Plus having an actual moving boat might bring up some issues like players potentially clipping through parts or general physics issues, like boat moving but not players, stuff like that.

im trying to sink the boat. if you didnt know lol

Yes, but if everything else rises, it would create the same effect as sinking the boat (relativity or something idk)

i got this working by adding a


between the bow and the stern tween and did what you told me to do thanks!

Oh okay, that’s good. If you need anything else make sure to ask.

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