Making Sliding Doors Faster

Good morning, i want to make my sliding doors faster sliding, idk why those are so slow, so i am asking for help. Dont change the value (0.01,0,0) please, because i need this value to get nice animation of sliding.

Here is the script:

local distance = 270
local d1 = script.Parent.Parent.Parent:WaitForChild(“Dzwi”)
local d2 = script.Parent.Parent.Parent:WaitForChild(“Dzwi2”)

script.Parent.Triggered:Connect(function(player)
if player.Character:FindFirstChild(“Card 1”) or player.Character:FindFirstChild(“Card 2”) then
script.Parent.Enabled = false
for i = 0, distance do
d1.Position -= Vector3.new(0.01,0,0)
wait(0)
d2.Position -= Vector3.new(-0.01,0,0)
wait(0)
end
wait(1)
for i = 0, distance do
d1.Position += Vector3.new(0.01,0,0)
wait(0)
d2.Position += Vector3.new(-0.01,0,0)
wait(0)
end
script.Parent.Enabled = true
end
end)

Im new scripter and i dont know reason, thanks for reading and help.

1 Like

Try Tweening it instead because you can pick how fast it goes

A video on how to make a sliding door here:

Tutorial on TweenService here:

Information about TweenService here:
https://developer.roblox.com/en-us/api-reference/class/TweenService

5 Likes

Creating this variable you can manage the aspect of the tween:

local Tweeninfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0) --Change 1 with the time you want it gets to tween and EasingStyle.Linear with the style you want, this is full customizable

An example:

local TweenService = game:GetService("TweenService")
local Tweeninfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0) --Change 1 with the time you want it gets to tween and EasingStyle.Linear with the style you want, this is full customizable
local Part = --Create the variable of the part to tween

local Open = {CFrame = CFrame.new(0, 0, 0) --Change this numbers with the position of the part when it is open
local Closed = {CFrame = CFrame.new(0, 0, 0) --Change this numbers with the position of the part when it is open

local OpenTween = TweenService:Create(Part, Tweeninfo, Open)
local CloseTween = TweenService:Create(Part, Tweeninfo, Closed)

To play the tween animation:

OpenTween:Play()
CloseTween:Play()
2 Likes

He didn’t use a tween though he just changed the position by 0.01