Hello, the lost people,
I am working on a door lock that can open when you touch the door with a key. But it doesn’t give any response and feedback. I wish I could fix this ASAP
Script:
local TweenService = game:GetService("TweenService")
local openAngle = 120
local keys = {
"YellowKey",
"RedKey"
}
local function unlockDoor(doorModel)
doorModel.Moving.Value = true
local doorinfo = TweenInfo.new(
0.7,
Enum.EasingStyle.Bounce,
Enum.EasingDirection.Out,
0,
false,
0
)
doorModel.PrimaryPart = doorModel.Hinge
local cframe = doorModel.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(1 * openAngle), 0)
local doorTween = TweenService:Create(doorModel.Hinge, doorinfo, {CFrame = cframe})
local sound = doorModel.Frame.Unlock
sound:Play()
doorTween:Play()
doorModel.Frame.CanCollide = false
doorTween.Completed:Wait()
doorModel.Frame.CanCollide = true
doorModel.Moving.Value = false
end
local doorLock = script.Parent
doorLock.Frame.Touched:Connect(function(hit)
if hit.Parent.Name == keys[doorLock.RequiredItem.Value] then
if doorLock.Moving.Value == false then
if doorLock.Opened.Value == false then
unlockDoor(doorLock)
doorLock.Opened.Value = true
end
end
end
end)