Lagging Door Animations

(I apologize if this is the wrong category)

Hello!

For some background, I have installed free model opening doors for my game, and I’ve noticed that as I add more to the game, the doors open slower and slower. I even timed how long it took for a door to open after the player clicked, and it came out to about a minute. I would assume this is lag…

My question is, how can I up the speed at which the doors open and close?

I’m not to sure why that is happening, maybe try and make opening the doors client sided for all players rather than server sided. Maybe you could give the model name for reference?

We need to see the code. Please post the code. Coderino. Code code code.

1 Like

It’s called “Click Door” it comes up fairly quickly if you search up doors in the toolbox. (Sorry for the late reply)

local door = script.Parent
local hinge = script.Parent.Hinge
local hingepos = hinge.Position
local tpart = script.Parent.Tpart.ClickDetector
local open = false
local db = false

tpart.MouseClick:Connect(function()

if db == false then 
if open == false then
	open = true
db = true

for i = 1, 26, 1 do
door:SetPrimaryPartCFrame(door:GetPrimaryPartCFrame(hingepos) * CFrame.Angles(0,math.rad(4),0,0) * CFrame.new(0,0,0))	
	wait()
end
db = false
elseif open == true and db == false then

for i = 1, 26, 1 do
door:SetPrimaryPartCFrame(door:GetPrimaryPartCFrame(hingepos) * CFrame.Angles(0,math.rad(-4),0,0) * CFrame.new(0,0,0))	
	wait()
open = false
db = true
end
db = false
end
end
end)

Replace wait with task.wait(). wait() is flooding the task scheduler and making it slower. task.wait() solves this.

1 Like

I would recommend using tweens, because they can do exactly what that script does but way more efficiently. I am sure that the issues you are having are purely due to the lag generated by the loops and constant stepping. Here is a link to the documentation, and I hope this helps!

Wouldn’t it be task.wait()? I tried task.wait. and now the door does not open at all.

Yes, if you want you could put a delay inside of the task.wait() (like task.wait(.25))

Yeah, I was thinking of that. I tried task.wait() and the door didn’t open then either. I’ll try putting a value in.

Edit: When I published it said that “uncommitted script changes have not been published”
What’s that mean?

Try disabling team create in View → Team Create → the 3 dots at the bottom or by closing the script menu and reopening it. I dont use team create so I am not sure though.

1 Like

It published this time, I’ll check to see if it worked.

Edit: It worked! Thanks so much!

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