I'm attempting to make automatic doors (where you hit a sensor and it opens :O), it does open, but extremely slowly and laggy. As can be seen here

local DoingSomething = false

local studs= 5
local speed = 0.1
local movements = studs/speed

local Model1 = script.Parent.Right
local Model2 = script.Parent.Left

script.Parent.Sensor.Touched:connect(function(player)
	if workspace.AirportOpen.Value then
		if player.Parent:FindFirstChild("Humanoid") then
			if not DoingSomething then
				DoingSomething = true
				for i=1,movements do
					wait()
					Model1:SetPrimaryPartCFrame(Model1.PrimaryPart.CFrame * CFrame.new(speed,0,0));
					Model2:SetPrimaryPartCFrame(Model2.PrimaryPart.CFrame * CFrame.new(-speed,0,0));
				end
				wait(3)
				for i=1,movements do
					wait()
					Model1:SetPrimaryPartCFrame(Model1.PrimaryPart.CFrame * CFrame.new(-speed,0,0));
					Model2:SetPrimaryPartCFrame(Model2.PrimaryPart.CFrame * CFrame.new(speed,0,0));
				end
				DoingSomething = false
			end
		end
	end
end)

Notes: This is not from my studio, this is in-game. This is on lowest graphics settings, this is the only script so far, and in the studio, it runs fine.

Any help would be appreciated, and even a better method would be appreciated too.

3 comments

0

It could have to do with the function your using to move the doors; have you considered TranslateBy() ? If not, it could be from your Studio Client just acting slow in general.

0

Lines 3, 4, and 5 don't make sense. What is 'studs'? Also I made a sliding door that you might want to dig through the code of: https://www.roblox.com/library/165295102/Fully-Customizable-Sliding-Door

0

^ Tried both of your solutions, didn't really work. Same results. Weird, considering every part is anchored, and the door only has parts inside of each model..