Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Is there a more efficient way for a Vector3 door?

Asked by
Qu_xtty -8
4 years ago

I think this speaks for itself.

local Detector = script.Parent.Button.ClickDetector local Door = script.Parent.Door

Detector.MouseClick:Connect(function(player)

Door.Position = Vector3.new(37.214, -45.200, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -45.100, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -45.000, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -44.900, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -44.800, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -44.700, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -44.600, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -44.500, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -44.400, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -44.300, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -44.200, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -44.100, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -44.000, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -43.900, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -43.800, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -43.700, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -43.600, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -43.500, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -43.400, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -43.300, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -43.200, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -43.100, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -43.000, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -42.900, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -42.800, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -42.700, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -42.600, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -42.500, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -42.400, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -42.300, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -42.200, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -42.100, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -42.000, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -41.900, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -41.800, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -41.700, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -41.600, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -41.500, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -41.400, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -41.300, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -41.200, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -41.100, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -41.000, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -40.900, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -40.800, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -40.700, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -40.600, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -40.500, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -40.400, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -40.300, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -40.200, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -40.100, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -40.000, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -39.900, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -39.800, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -39.700, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -39.600, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -39.500, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -39.400, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -39.300, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -39.200, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -39.100, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -39.000, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -38.900, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -38.800, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -38.700, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -38.600, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -38.500, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -38.400, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -38.300, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -38.200, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -38.100, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -38.000, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -37.900, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -37.800, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -37.729, -46.821)
wait(2)
Door.Position = Vector3.new(37.214, -37.800, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -37.900, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -38.000, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -38.100, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -38.200, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -38.300, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -38.400, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -38.500, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -38.600, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -38.700, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -38.800, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -38.900, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -39.000, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -39.100, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -39.200, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -39.300, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -39.400, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -39.500, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -39.600, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -39.700, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -39.800, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -39.900, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -40.000, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -40.100, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -40.200, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -40.300, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -40.400, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -40.500, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -40.600, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -40.700, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -40.800, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -40.900, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -41.000, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -41.100, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -41.200, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -41.300, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -41.400, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -41.500, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -41.600, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -41.700, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -41.800, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -41.900, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -42.000, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -42.100, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -42.200, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -42.300, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -42.400, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -42.500, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -42.600, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -42.700, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -42.800, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -42.900, -46.821)
wait(.000001)
Door.Position = Vector3.new(37.214, -43.000, -46.821)
wait(.000001)

NOTE: I cut this down in order for it to be under 10000 characters, there is a total of 312 lines.

1 answer

Log in to vote
0
Answered by 4 years ago

Hello. The first thing I have to say is, well, wow. Anyways you can use TweenService or Vector3:Lerp().

TweenService:

local TweenService = game:GetService("TweenService")

local info = TweenInfo.new(
    1, -- Tween Time
    Enum.EasingStyle.Sine, -- EasingStyle
    Enum.EasingDirection.Out, -- EasingDirection
)

local goal = {Position = Vector3.new(X, Y, Z)}

local tween = TweenService:Create(script.Parent.Door, info, goal)

script.Parent.Button.ClickDetector.MouseClick:Connect(function()
    tween:Play()
end)

Change "X, Y, Z" to the goal position.

Vector3:Lerp():

script.Parent.Button.ClickDetector.MouseClick:Connect(function()
    for i = 0, 1, 0.01 do 
        wait()
        script.Parent.Door.Position:Lerp(Vector3.new(X, Y, Z), i)
    end
end)

Change "X, Y, Z" to the goal position.

There is not really a difference between Lerping and TweenService, but I'd use TweenService since it has things like time, EasingStyle, etc. Please accept this answer and upvote it if it helped.

0
All I did was revert the position and location of the clickdetector and it wont work. Qu_xtty -8 — 4y
0
I also put the script inside the door that i had the 313 long script in, i changed the x, y, z, to the position and it didnt work. Qu_xtty -8 — 4y
0
Weird. It should work. youtubemasterWOW 2741 — 4y
Ad

Answer this question