Hello! I am currently working on a site for a SCP group, however some scripts are extremely slow. Most scripts work fine, but the doors are extremely slow. (Please look at the footage below for comparisons!) I have tried removing some useless parts/models, I have tried adding some anti lag scripts, however none have worked so far.
Oh yes, here is some more detail: It seems that when the server first starts, the doors are a bit slow, but if the server has been running for over 3 minutes, the doors start getting extremely slow. For anyone who’s wondering, I have a Windows 10 laptop, I3 core, 8 GB ram. But the issue is happening to everyone, not just me.
Video 1:
I made a baseplate and added the same doors
Okay, I got a few suggestions here that might work, however first:
GET RID OF ANY ANTI LAG SCRIPTS!!!
They don’t remove any lag in your game at all, don’t believe that they will as they definetly do not!
Anyway, if you move your doors on the server, it’ll be dependant on the performance of the server. It’d be helpful if you could share the doors code so we can see whats wrong in specific, however at first glance, if you are referring to the movement of the massive door, then I’d play around with the time it takes for that door to open in it’s script. The jittering is a side effect of CFraming from one point to another, so it may be worth altering that to use something like TweenService, or even having doors move on the client.
This would not be an issue with the scripts that he has, as he isn’t using PrimaryPart’s and models. He’s moving very few parts at the same time.
I would recommend looking into the use of TweenService or similar, as they are way more effective methods of moving parts or dynamically interpolating properties of an object ( like rainbow bricks for example.) You could use it in this instance by using the lookvector and setting an “Open” Goal and “Close Goal”
local DoorPart = -- door part here
local OriginalCFrame = -- door CFrame here
local Offset = -- door's destination here
local Open = false
local Moving = false
local toggleDoor()
assert(Moving == false, "Door is moving, cannot be opened.") -- good for debugging
Moving = true
if Open then
local Tween = game:GetService("TweenService"):Create(Door,TweenInfo.new(1),{CFrame = Offset})
Tween:Play()
Tween.Completed:Wait()
else
local Tween = game:GetService("TweenService"):Create(Door,TweenInfo.new(1),{CFrame = OriginalCFrame})
Tween:Play()
Tween.Completed:Wait()
end
Moving = false
end
My code is quite scruffy but I suggest you adapt this concept, along side the TweenService API to see if you can make these doors both more efficient and easier to code. Using a for loop for CFrame is generally an older method used in previous years.
Before I give you some advise I just need to point out that using external scripts can be more harmful than helpful as usually these contain some sort of backdoor which can allow exploiters to have full access to the server.
Causes
Often times when lag like this occurs it’s because of a high part count however, this is not the only cause of this!
Sometimes, poorly written scripts using lots of loops and creating many instances can affect your performance by a huge amount.
Malicious plugins or scripts that you insert into your game can also cause lag such as this if they are purposely slowing your game down just to be annoying or if it’s unintentional and because of poorly written malicious code.
How to solve
Try the property in Workspace known as “Streaming Enabled”
Please note: Although streaming can help with lag some developers may prefer it to be switched off as some things may not function correctly with it enabled such as instantly referencing a part after it’s been added out of the streaming radius.
Rewrite your scripts. This is a bit blunt but sometimes just going over your scripts and reviewing what you have wrote can be beneficial. You may catch something you did wrong that causes the lag.
Get a malicious plugin/script remover. Yes this is sort of funny since you are getting a plugin to remove a malicious one which could also be an infected one however, if you search around on the DevForum you should be able to find some trusted malicious plugin and script removers which work very well and can remove any unwanted scripts that may cause lag.
Take a look at the Developer Console!
This can really help you narrow down where the lag is coming from.