Having problems with body detector

So I’m trying to make a door that slowly opens when someone touches an invisible part,idk how to make one but here’s what I made so far

local Left = script.Parent.LeftDoor

local Touch = script.Parent.Touch

local Right = script.Parent.RightDoor

Touch:FindFirstChild()

if

Left.Position = Vector3.new(178, 21.326, -188.446)

Right.Position = Vector3.new(156, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(179, 21.326, -188.446)

Right.Position = Vector3.new(155, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(180, 21.326, -188.446)

Right.Position = Vector3.new(154, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(181, 21.326, -188.446)

Right.Position = Vector3.new(153, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(182, 21.326, -188.446)

Right.Position = Vector3.new(152, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(183, 21.326, -188.446)

Right.Position = Vector3.new(151, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(184, 21.326, -188.446)

Right.Position = Vector3.new(150, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(185, 21.326, -188.446)

Right.Position = Vector3.new(149, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(186, 21.326, -188.446)

Right.Position = Vector3.new(148, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(187, 21.326, -188.446)

Right.Position = Vector3.new(147, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(188, 21.326, -188.446)

Right.Position = Vector3.new(146, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(189, 21.326, -188.446)

Right.Position = Vector3.new(145, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(189, 21.326, -188.446)

Right.Position = Vector3.new(145, 21.326, -188.461)

Hey. Instead of going through all the hassle, you can just tween the door’s position/rotation. Can you send sth like an expected result?

Here’s what you should do:

Part.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") then
-- Code here
end
end)

-- For moving door
local TweenService = game:GetService("TweenService")
local TweenInformation = TweenInfo.new(
5, -- Time for the Tween to Play
Enum.EasingStyle.Linear, -- Style to move, experiment with it
Enum.EasingDirection.Out, -- Direction to move, can experiment
0, -- Times to repeat
false, -- Repeat tween?
0 -- Delay between each repetition
)

local PropertiesTable = {
Position = -- Position to move here
}

local Tween = TweenService:Create(Door, TweeningInformation, PropertiesTable)
Tween:Play()
-- More on TweenService https://developer.roblox.com/en-us/api-reference/class/TweenService
1 Like