How can I stop my keycard door from spamming code?
Asked by
4 years ago Edited 4 years ago
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
02 | local tweenService = game:GetService( "TweenService" ) |
04 | Position = Vector 3. new(- 67.9 , 3.175 , 20.975 ) |
06 | local tweeninfoo = TweenInfo.new( 1.65 ,Enum.EasingStyle.Linear,Enum.EasingDirection.Out) |
07 | local tween = tweenService:Create(script.Parent,tweeninfoo,properties) |
08 | if debounce = = false then |
open anim
1 | local tweenService = game:GetService( "TweenService" ) |
3 | Position = Vector 3. new(- 67.9 , 8.675 , 20.975 ) |
5 | local TweenInfoo = TweenInfo.new( 1.55 ,Enum.EasingStyle.Linear,Enum.EasingDirection.Out) |
6 | local tween = tweenService:Create(script.Parent,TweenInfoo,properties) |
keycardclose
01 | local part = script.Parent |
02 | local door = script.Parent.Parent.Door |
06 | script.Parent.Touched:Connect( function (hit) |
07 | if debounce = = false then |
09 | 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 |
10 | if door.openn.Disabled = = false then |
11 | door.openn.Disabled = true |
12 | door.closee.Disabled = false |
15 | elseif hit.Parent.Name = = part.Low.Value then |
18 | part.KeyCardOpen.Disabled = false |
20 | script.Disabled = true |
keycardopen
01 | local part = script.Parent |
02 | local door = script.Parent.Parent.Door |
06 | script.Parent.Touched:Connect( function (hit) |
07 | if debounce = = false then |
09 | 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 |
10 | if door.closee.Disabled = = false then |
11 | door.closee.Disabled = true |
12 | door.openn.Disabled = false |
15 | elseif hit.Parent.Name = = part.Low.Value then |
19 | part.KeyCardClose.Disabled = false |
20 | script.Disabled = true |
Here's the debugger (it's basically not)
2 | if script.Parent.KeyCardClose.Disabled = = true and script.Parent.KeyCardOpen.Disabled = = true then |
3 | script.Parent.KeyCardOpen.Disabled = false |