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

i tried debounce my script but failed?can someone edit my script to debounce

Asked by 4 years ago
Edited 4 years ago

can u add wait(8.5) in there

can u debounce open door and close door coz they arent the same function, (the door either opens or closes not both)

local hit = false

local keycard = "Keycard"

script.Parent.Touched:Connect(function(hit)

local character = hit.Parent

local player = game.Players:GetPlayerFromCharacter(character)

if player then

local backpack = player.Backpack

if backpack:FindFirstChild(keycard) or character:FindFirstChild(keycard) then

print("opendoor")

else

print("closedoor")

end

end

end)

0
no do it yourself. THIS IS NOT A REQUEST SITE Itzlewis99 26 — 4y
0
i tried IckyInvin5ible7 -70 — 4y
0
Chill Spjureeedd 385 — 4y
0
Please use codeblocks. It is easier to help you when you do. Geobloxia 251 — 4y
0
codeblocks? IckyInvin5ible7 -70 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Code blocks are these ~~~~~~~~~~~~~~~~~

Edit: I did 2 things wrong. Sorry, problem 1 was that the debounce variable name was the same as the name of the input. Problem 2, I didn't even use the debounce as a checking point.

local inside = false

local keycard = "Keycard"

script.Parent.Touched:Connect(function(hit)
    local character = hit.Parent
    local player = game.Players:GetPlayerFromCharacter(character)
    if player and inside == false then
        inside = true
        local backpack = player.Backpack     
        if backpack:FindFirstChild(keycard) or character:FindFirstChild(keycard) then
            print("opendoor")
        else
            print("closedoor")
        end
        wait(8.5)
        inside = false
    end
end)
0
didnt work ;-; IckyInvin5ible7 -70 — 4y
0
Oh I know why BradNewTypical 232 — 4y
Ad

Answer this question