CPU time increases when characters sits on seat

Hello, everyone! I’m working on my game and I’ve noticed really weird issue, when I sit on ANY seat in my game CPU time increases in MicroProfiler (from 4ms to 9ms) and I notice FPS drop for a few renders (from 300 to 100). Other players notice this issue too. I’ve attached screenshots from Microprofiler. This is my first time using Microprofiler so I don’t really know what I need to add in this post, would be happy if you tell me what I should do. Thanks for any help!

Game using R6 rig.

Also, sorry if I’ve posted it in the wrong section. I have one single script for character that plays animation depending on the seat, I tried to disable it and I haven’t noticed any changes.

Before seating
Before humanoid seats
On the moment when Humanoid seats
Right after humanoid seats

4 Likes

If you are sure that this is a bug, you may want to make a post in #bug-reports so that the Roblox developers can fix this.

1 Like

I’m not sure it’s engine bug, since I do not see this problem in other places. :frowning:

1 Like

Is there any code you have related to the seat? Your code could be causing a memory leak.

1 Like

I stated in post that I have only one script that work with seats. I tried disabling it but anyway it does not help, still same

1 Like

Sorry, didn’t see that in the post. Try going into an empty game and create a seat, without any scripts present at all and see if the issue still occurs.

2 Likes

Just tried with empty place with a few seats. I don’t see any problems with CPU time increase.

Must be something to do with your game then. How many other scripts do you have? (whether they are related to the seat or not), just wondering if you have a lot or a small amount.

I have a bunch of scripts but the only one works with seats. (Server)
I don’t think it may cause issue. Added below.

return function(Player: Player, Character)
	local Humanoid: Humanoid = Character:WaitForChild('Humanoid', 9e9)
	local track
	local Animation
	
	Humanoid:GetPropertyChangedSignal('SeatPart'):Connect(function()
		if track then
			track:Stop()
		end
		
		local SeatPart = Humanoid.SeatPart
		
		if SeatPart and SeatPart:GetAttribute('SitAnimation') then
			Animation = Instance.new('Animation')
			Animation.AnimationId = 'rbxassetid://' .. SeatPart:GetAttribute('SitAnimation')
			Animation.Name = 'sitAnimation'
			
			track = Humanoid.Animator:LoadAnimation(Animation)
			track:Play()
		end
	end)
end

is this the full script? it doesn’t seem like it. ( I just haven’t seen a script like this before, could be my bad lol)

Maybe the localscripts may cause, I’ll try disabling all of them. Will tell later

Yes. It’s modulescript that being fired with following code

local function characterAdded(Character)
	for _, v in pairs(modules.character) do
		task.spawn(v, Player, Character)
	end
end
	
if Player.Character then
	characterAdded(Player.Character)
end

okay, try disabling the localscripts then i guess.

Same result. Disabled all localscripts in StarterCharacterScripts, StarterPlayerScripts, StarterGui. I suppose it could be related to building. Thank you for trying to help me. I think that’s all.

Alright, good luck on finding the issue! (I really have no idea, I think it must be somehow related to another script you have which doesn’t seem to be related to seats, or building like you said)

Isn’t there a debugging tool that displays which script is taking up more memory?

I have identified that it’s not scripting related issue.

I was just wondering if you’ve put a free model in there, or used a malicious plugin (or in TeamCreate a friend has used a plugin) that’s making the lag occur.

Also, you are loading the animation every time a player changes a seat property in that script.
Load it in the Players at the beginning of the script so it doesn’t load every time, then just play or stop it.

I’m 100% it’s not malicious script. (checked all scripts) Anyway, I disabled script that plays animation and can say that’s not script issue.

EDIT: This was building related issue, after we optimized the building itself fps drops are no longer a thing

Is the seat unanchored or welded to an unanchored part? Sitting on an unanchored seat causes CPU times to increase dramatically, I’m unsure why that is the case.