#Door

24 messages · Page 1 of 1 (latest)

peak loom
#

So I want to make it so a animation plays depending on wish side of the door you're on (using tween service) but the problem is that I don't know how to make the script detect wish side of the door the player is on

peak loom
#

I think i found a method using a hidden part as the player detector and a table to store players inside of that hitbox part

limpid moon
peak loom
#

but Im trying to figure out how to not make it delete everyone in the table as soon as the player leaves

limpid moon
peak loom
# limpid moon Why would it delete everyone from the table?
    if hit.Parent:FindFirstChild("Humanoid")  and not table.find(playerInTheBackSide, hit.Parent)then
    table.insert(playerInTheBackSide,hit.Parent)
    end
    print(playerInTheBackSide)
end)
backside.TouchEnded:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        table.remove(playerInTheBackSide, table.find(playerInTheBackSide, hit.Parent))
    end
    print(playerInTheBackSide)
end)```
prints a empty table if there's 2 players inside of the part.touched  and one of them stops touching
limpid moon
peak loom
#

yep that works

#

it deleted every humanoid touching it before

limpid moon
peak loom
#

ive never used debounce

#

😭

#

or heard of it

#

tbh

limpid moon
#

They're really useful for when you don't want a piece of code to run way too often

peak loom
#

oh a cooldown function

#

i just looked it up

limpid moon
#

e.g. .Touched can fire a few hundred times within a second (or some other arbitrary number, larger than the optimal "1") . In that case just use a debounce to only take 1 inout per a frame or something similar

peak loom
#

thanks for the idea

#

ye it does print the table like 17 times everytime its hit

peak loom
limpid moon
#
if hit.Parent:FindFirstChild("Humanoid")  and not table.find(playerInTheBackSide, hit.Parent) and backdeb then
    backdeb = false
    table.insert(playerInTheBackSide,players:GetPlayerFromCharacter(hit.Parent))
    task.wait(0.1)
    backdeb =true
end