Hello, the lost people,
I am working on an escape door/lock for my coming soon game. There no error at the output, it just doesn’t work. Hope you all can help :>
local TweenService = game:GetService("TweenService")
local openAngle = 90
local breaked = false
local unlocked = false
local fixed = false
local requiredItems = {
"Crowbar" or "Hammer",
"Wrench",
"White Key"
}
local function animateDoor(model)
model.Moving.Value = true
local doorInfo = TweenInfo.new(
0.7,
Enum.EasingStyle.Bounce,
Enum.EasingDirection.Out,
0,
false,
0
)
model.PrimaryPart = model.Hinge
local cframe = model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(1 * openAngle), 0)
local doorTween = TweenService:Create(model.Hinge, doorInfo, {CFrame = cframe})
local sound = model.Frame.Creak
sound:Play()
doorTween:Play()
doorTween.Completed:Wait()
model.Moving.Value = false
end
local function fixSwitch(model)
local lightTween = TweenService:Create(model.Switch.Light, TweenInfo.new(1), {Color = Color3.new(0.133333, 1, 0.0901961)})
lightTween:Play()
end
script.Parent.Frame.Touched:Connect(function(hit)
if CollectionService:HasTag(hit.Parent, "Item") then
if hit.Parent.Name == requiredItems[1] and not breaked then
breaked = true
script.Parent.Planks:Destroy()
script.Parent.Frame.Break:Play()
script.lock.Value -= 1
end
if hit.Parent.Name == requiredItems[2] and not fixed then
fixed = true
fixSwitch(script.Parent)
script.Parent.Frame.Fixed:Play()
script.lock.Value -= 1
end
if hit.Parent.Name == requiredItems[3] and not unlocked then
unlocked = true
script.Parent.Padlock:Destroy()
script.Parent.Frame.Unlock:Play()
script.lock.Value -= 1
end
end
end)
if script.lock.Value < 1 then
if script.Parent.Moving.Value == false then
if script.Parent.Opened.Value == false then
animateDoor(script.Parent)
script.Parent.Opened.Value = true
end
end
end