Hello!
Yes. I’m back after many months with another problem.
So I have a keycard door that uses TweenService
(Credit to TheDevKing)
The problem is, everytime it accepts the keycard and tries to open the door it puts it (probally) at 0,0,0.
Code (Normal Script)
local OpenTweenVector3 = Vector3.new(-13.5, 3.65, -268.552)
local CloseTweenVector3 = Vector3.new(-13.5, 3.65, -272.152)
local TweenService = game:GetService("TweenService")
local Part = script.Parent.Parent.Parent.Door
local Delayed = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent.Name == "EnginnerKeycard" and Delayed == false then
Delayed = true
print("Delayed is set to true")
script.Parent.Parent.Color.BrickColor = BrickColor.new("Bright green")
script.Parent.Parent.Parent.KeycardReader2.Color.BrickColor = BrickColor.new("Black")
script.Parent.Parent.Parent.KeycardReader2.Sensor.Script.Disabled = true
script.OpenTween.Position.Value = OpenTweenVector3
script.CloseTween.Position.Value = CloseTweenVector3
require(script.OpenTween)
wait(3)
require(script.CloseTween)
script.Parent.Parent.Color.BrickColor = BrickColor.new("Bright red")
wait(1.5)
Delayed = false
print("Delayed is set to false")
script.Parent.Parent.Parent.KeycardReader2.Color.BrickColor = BrickColor.new("Bright red")
script.Parent.Parent.Parent.KeycardReader2.Sensor.Script.Disabled = false
script.OpenTween:Remove()
script.CloseTween:Remove()
game.ReplicatedStorage.TweensSingleDoor.OpenTween:Clone().Parent = script
game.ReplicatedStorage.TweensSingleDoor.CloseTween:Clone().Parent = script
wait(0.095)
script.OpenTween.Position.Value = OpenTweenVector3
script.CloseTween.Position.Value = CloseTweenVector3
end
end)
I forgot to put the ModuleScript
local OpenTween = {}
local TweenService = game:GetService("TweenService")
local Part = script.Parent.Parent.Parent.Parent.Door
local Info = TweenInfo.new(
1.5,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local Goals =
{
Position = Vector3.new(script.Position);
}
local Tween = TweenService:Create(Part, Info, Goals)
Tween:Play()
return OpenTween
Here’s a video to:
You can tell that the door is moved by looking at the reflection