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
wait()
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
break
end
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});
tween:Play();
tween.Completed:Wait();
end
--|< 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
break;
end
end
^
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.