How to remove game lag (No fps lost)

Hello there!
I’m working on a city rp game with a team.
But we’re having some issues, and one of them is in-game lag but no fps lost.

Some stuff wont move or will take a lot of time to load / work, but we don’t experience less fps.

Here’s an example:

The door is supposed to move in 1 second, but it takes 10-15 seconds. (The video shows fps lost but it’s because of my film maker. There’s no FPS lost in game)

  • The door is only an example of it, there are some other stuff with the same problem.

Here’s another example:
robloxapp-20210110-1734196.wmv (271.0 KB)

We’ve been tried to search for anti-lag system or something.

So I wanted to know if theres any script or solution for that, if there is we would appreciate it a lot! Thank you :slight_smile:

3 Likes

Is it because of replication? If the server is the one that opens the door, and you have a pretty low ping, then that may be why. Try to have the clients open the door and not the server for a much faster and smoother effect. Use RemoteEvents if necessary.

3 Likes

Well, I used a normal script for the door, and as I know it’s a server script. I will try to do it as you say. Thank you!

There is no such thing as an anti lag script, but it would be pretty cool if there were. As it stands, anything that actually makes a noticeable difference needs to be handled on a case-by-case basis.

That said, can you show me the script that handles the door? Even if it’s handled by the server, it should not be that bad.

1 Like

Well this is the script.
local TimeAfterClose = 3
local Hinge = script.Parent.PrimaryPart
local opened = false

function OpenDoor()
if opened == false then
opened = true
for i = 1, 21 do
script.Parent:SetPrimaryPartCFrame(Hinge.CFrameCFrame.Angles(0, math.rad(5), 0))
wait()
end
wait(TimeAfterClose)
for i = 1, 21 do
script.Parent:SetPrimaryPartCFrame(Hinge.CFrame
CFrame.Angles(0, math.rad(-5), 0))
wait()
end
opened = false
end
end

script.Parent.Handle1.ClickDetector.MouseClick:Connect(OpenDoor)
script.Parent.Handle2.ClickDetector.MouseClick:Connect(OpenDoor)

I got based off a video.

Also as I say, the door is not the only one that gets that issue, there are some other stuff as well.

1 Like

I want y’all to know that I tested the door and some other stuff in another place with not that much blocks and it worked perfect

2 Likes

Replace wait() with game.RunService.RenderStepped:wait() and I think you should be good. The script is not well written in general, so this is not a good permanent solution, but I think it should fix the issue.

2 Likes

Thank you, Im gonna check that

1 Like

Maybe it needs more time to open? Probably change it to like 3 seconds.

2 Likes

Use hinge constraints and springs for the door. It wont need any scripts unless you want to make it lockable and unlockable.

3 Likes

I would also watch the part count, and use meshes instead of parts.

2 Likes

I heard some where the more you move an object the more the game will lag. (Don’t take my word for it because I just saw this in a discord server.)

2 Likes

Looking at this script; you are using a for i loop but not actually using i, you are just setting the angle to 5* 21 times for no reason with a wait, so each loop is taking 21*0.03 seconds to finish

There is no issue with game lag the script just isnt working.

2 Likes

Alright! I’ll check that and modify the script. Thank you!

1 Like

Yea, but it is when you have many bricks in a model and you move them

1 Like

Thank you! I’ll try and see if it’s better!

1 Like

Alright, i’ll check thank you!

1 Like

That’s a numeric for loop, and it is the correct thing to use for this situation. Unless you know of something better?

1 Like

game.Workspace.StreamingEnabled

Also unions cause lag. I would look at those, and make sure there are no viruses in your game.
Unanchored parts also cause lag also.

1 Like

Alright! I will check that stuff. Also I don’t have any viruses or free models, But yes. many unions. Thank you!

1 Like