I'm fairly new to lua and I can't figure out how to fix my door. When I touch the keycard scanner with a card, it works at first but when closing, it plays the audio but it doesn't go down all the time, I would assume one of the scripts are spamming code. Would there be a way to fix this?
Here's the code I'm working with and a image to show how it works:
https://streamable.com/yocafq
close anim
local debounce = false local tweenService = game:GetService("TweenService") local properties = { Position = Vector3.new(-67.9, 3.175, 20.975) } local tweeninfoo = TweenInfo.new(1.65,Enum.EasingStyle.Linear,Enum.EasingDirection.Out) local tween = tweenService:Create(script.Parent,tweeninfoo,properties) if debounce == false then debounce = true tween:Play() wait(.1) debounce = false end
open anim
local tweenService = game:GetService("TweenService") local properties = { Position = Vector3.new(-67.9, 8.675, 20.975) } local TweenInfoo = TweenInfo.new(1.55,Enum.EasingStyle.Linear,Enum.EasingDirection.Out) local tween = tweenService:Create(script.Parent,TweenInfoo,properties) tween:Play()
keycardclose
local part = script.Parent local door = script.Parent.Parent.Door local debounce = false script.Parent.Touched:Connect(function(hit) if debounce == false then debounce = true if hit.Parent.Name == part.two.Value or part.three.Value or part.four.Value or part.five.Value or part.omni.Value or part.omega.Value then if door.openn.Disabled == false then door.openn.Disabled = true door.closee.Disabled = false door.Close:Play() end elseif hit.Parent.Name == part.Low.Value then door.Audio:Play() end part.KeyCardOpen.Disabled = false wait(1.65) script.Disabled = true wait(.01) debounce = false end end)
keycardopen
local part = script.Parent local door = script.Parent.Parent.Door local debounce = false script.Parent.Touched:Connect(function(hit) if debounce == false then debounce = true if hit.Parent.Name == part.two.Value or part.three.Value or part.four.Value or part.five.Value or part.omni.Value or part.omega.Value then if door.closee.Disabled == false then door.closee.Disabled = true door.openn.Disabled = false door.Open:Play() end elseif hit.Parent.Name == part.Low.Value then door.Audio:Play() end wait(1.55) part.KeyCardClose.Disabled = false script.Disabled = true debounce = false end end)
Here's the debugger (it's basically not)
while wait(.01) do if script.Parent.KeyCardClose.Disabled == true and script.Parent.KeyCardOpen.Disabled == true then script.Parent.KeyCardOpen.Disabled = false end end