Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

01local debounce = false
02local tweenService = game:GetService("TweenService")
03local properties = {
04    Position = Vector3.new(-67.9, 3.175, 20.975)
05}
06local tweeninfoo = TweenInfo.new(1.65,Enum.EasingStyle.Linear,Enum.EasingDirection.Out)
07local tween = tweenService:Create(script.Parent,tweeninfoo,properties)
08if debounce == false then
09debounce = true
10tween:Play()
11wait(.1)
12debounce = false
13end

open anim

1local tweenService = game:GetService("TweenService")
2local properties = {
3    Position = Vector3.new(-67.9, 8.675, 20.975)
4}
5local TweenInfoo = TweenInfo.new(1.55,Enum.EasingStyle.Linear,Enum.EasingDirection.Out)
6local tween = tweenService:Create(script.Parent,TweenInfoo,properties)
7 
8tween:Play()

keycardclose

01local part = script.Parent
02local door = script.Parent.Parent.Door
03local debounce = false
04 
05 
06    script.Parent.Touched:Connect(function(hit)
07    if debounce == false then
08        debounce = true
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
13            door.Close:Play()
14            end
15            elseif hit.Parent.Name == part.Low.Value then
View all 24 lines...

keycardopen

01local part = script.Parent
02local door = script.Parent.Parent.Door
03local debounce = false
04 
05 
06    script.Parent.Touched:Connect(function(hit)
07    if debounce == false then
08        debounce = true
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
13            door.Open:Play()
14            end
15        elseif hit.Parent.Name == part.Low.Value then
View all 23 lines...

Here's the debugger (it's basically not)

1while wait(.01) do
2if script.Parent.KeyCardClose.Disabled == true and script.Parent.KeyCardOpen.Disabled == true then
3    script.Parent.KeyCardOpen.Disabled = false
4end
5end

Answer this question