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?
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)
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!
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.