Hello. I have some automatic doors and other tweened objects such as an elevator that typically work smoothly. The game is relativly small however, about 25% of a time when I join a new server, all of the Tweened bricks/models lag resulting in choppy animations. Why is this and how can I fix this? The code works 75% of the time and I believe it might be a problem on Roblox's side.
open = false
door1 = script.Parent.Parent.RightDoor.Door
door2 = script.Parent.Parent.LeftDoor.Door
local thud = 183859526
local hydraulicLoop = 1842956861
local sound = Instance.new("Sound")
sound.Parent = script.Parent
sound.MaxDistance = 70
sound.PlaybackSpeed = 0.9
local TweenService = game:GetService("TweenService")
local part = script.Parent
local tweenInfo = TweenInfo.new(2,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
local Door1Open = {CFrame = door1.CFrame + door1.CFrame.lookVector * -3.5}
local Door2Open = {CFrame = door2.CFrame + door2.CFrame.rightVector * -3.5}
local Door1Close = {CFrame = door1.CFrame}
local Door2Close = {CFrame = door2.CFrame}
local Open1 = TweenService:Create(door1,tweenInfo,Door1Open)
local Open2 = TweenService:Create(door2,tweenInfo,Door2Open)
local Close1 = TweenService:Create(door1,tweenInfo,Door1Close)
local Close2 = TweenService:Create(door2,tweenInfo,Door2Close)
script.Parent.Touched:connect(function()
if open == false then
sound.SoundId = "http://www.roblox.com/asset/?id="..hydraulicLoop
Open1:Play()
Open2:Play()
open = true
sound:Play()
wait(5)
sound:Play()
Close1:Play()
Close2:Play()
open = false
end
end)

6 comments
Are you using the actual TweenService or are you doing stuff with for loops?
I recommend using Render Stepped for the most tweening part due to its smoothness as it waits 1/60 seconds.
I am using TweenService. I posted the code above just now.
I tried using HeartBeat because my code is in a server script but I still have problems.
Say, is this a regular Script running on the server?
Correct, this is a server script