#Door bug

1 messages · Page 1 of 1 (latest)

odd gyro
#

When I try to make multiple rooms doors, every parts that should open their door, only open the 1st door. (If this is confusing, here's a video)
Script:

local openPart = script.Parent
local ts = game:GetService("TweenService")
local db = true

local info = TweenInfo.new(
    3,
    Enum.EasingStyle.Exponential,
    Enum.EasingDirection.Out,
    0,
    false,
    0
)
local open = ts:Create(door, info, {CFrame = door.CFrame + Vector3.new(0,0,4.72)})
local close = ts:Create(door, info, {CFrame = door.CFrame})

openPart.Touched:Connect(function(hit)
    if db and hit.Parent:FindFirstChild("Humanoid") then
        db = false
        open:Play() open.Completed:Wait() task.wait(1)
        close:Play() close.Completed:Wait() task.wait(0.5)
        db = true
    end
end)

location of the door:

lofty venture
#

If I’m understanding this correctly you making a duplicate of that model creates a new script, which is a big no no if doing multiple models or parts with the same functionality.

gritty walrusBOT
#

studio** You are now Level 4! **studio

lofty venture
#

You should use “CollectionService” and a “for _, v loop”

#

I can help u with the script later if u want

#

@odd gyro

lofty venture
odd gyro
lofty venture
odd gyro
#

Should I name every cells like
Cell1
Cell2
Cell3,etc...
and modify the script with it ?

lofty venture
#

Place the script inside SSS

odd gyro
#

I'm still a beginner at programming lol

#

alr

lofty venture
#

Deleted the local door variable

odd gyro
#

I put it

#

do I let the OpenPart ?

#

because the script was in it

#

so it means that there is no script.Parent

lofty venture
#

Yea

odd gyro
#

ok

#

I did it but now it's doing errors here bru

lofty venture
#

It’s alright don’t worry about them

odd gyro
#

ok

lofty venture
#

Do: local collectionService = game:GetService(“CollectionService”)

odd gyro
#

oka

#

lemme check what is a CollectionService

lofty venture
#

Okay

odd gyro
#

oh

#

so you are gonna make a group

lofty venture
#

Nah u need to make a tag inside the door part u want to move

#

And name it what ever u want to name it

odd gyro
#

a local tag or smth ?

#

oh no inside of the door

#

i'm dumb

#

I created it

#

DoorTag

lofty venture
#

lol, alright

odd gyro
#

What do I do next ?

lofty venture
#

Now create a variable like this: local doors = collectionService:GetTagged(“DoorTag”)

odd gyro
#

alr

lofty venture
#

The actual tween info and stuff inside of this loop: for_, door in pairs(doors) do
[stuff here]
end)

#

And let me know if there’s any errors

odd gyro
#

This ?

#

or the event .Touched with it

lofty venture
#

The touched event also

odd gyro
#

ok

#

Should I also do a tag for the OpenPart ?

lofty venture
#

And make a variable named: local openPart = door:WaitForChild([instance name here])

odd gyro
#

below "for _,door in pairs(doors) do" ?

lofty venture
#

Local openPart = door:WaitForChild()

odd gyro
#

OH NO IM STUPID

#

yea I just figured out looking at the screenshot

#

sorry

#

what's the instance btw ?

#

the location of the part ?

#

or the name

lofty venture
#

The name

odd gyro
#

So this

odd gyro
lofty venture
#

Yes

odd gyro
lofty venture
#

If it’s still not working give me a few mins

odd gyro
#

It is not It's saying " Infinite yield possible on 'Game:WaitForChild("DoorPrimaryPart")"

#

but I never told the script to do this

lofty venture
#

I see the problem

odd gyro
#

so I don't know why it's doing this

#

wait

#

I did 2 scripts idk why

#

let me fix it

odd gyro
#

and the 3 here is doing an error

lofty venture
#

Place the tags inside the primarydoorparts

#

My bad I was reading the script to fast

odd gyro
#

that's what I did

gritty walrusBOT
#

studio** You are now Level 17! **studio

lofty venture
#

“DoorPrimaryPart”?

odd gyro
#

yes

lofty venture
#

What’s the child inside the DoorPrimaryPart?

odd gyro
#

it was made of multiple parts so

lofty venture
#

Where is the OpenPart located

gritty walrusBOT
#

studio** You are now Level 5! **studio

odd gyro
lofty venture
#

That should be the last thing I need to figure out

odd gyro
#

at the same place

lofty venture
#

So from the looks of the img the OpenPart is not located inside the DoorPrimaryPart, but instead it’s located in the parent of the DoorPrimaryPart

odd gyro
#

It is not connected to the DoorPrimaryPart

lofty venture
#

Then u need to change the line of code to: door.Parent.Parent:WaitForChild(“OpenPart”)

#

Don’t forget the “ “

odd gyro
#

It's still doing this even after I put it

lofty venture
#

Show me the parent inside the properties tab of the OpenPart

odd gyro
lofty venture
#

Oh my mistake, you just need to do one .Parent

odd gyro
#

why are the errors like this only happening to me

#

here's the script

#
local cs = game:GetService("CollectionService")
local doors = cs:GetTagged("DoorTag")
local ts = game:GetService("TweenService")
local db = true

for _,door in pairs(doors) do
    local openPart = door.Parent:WaitForChild("OpenPart")
    local info = TweenInfo.new(
    3,
    Enum.EasingStyle.Exponential,
    Enum.EasingDirection.Out,
    0,
    false,
    0
)
local open = ts:Create(door, info, {CFrame = door.CFrame + Vector3.new(0,0,4.72)})
local close = ts:Create(door, info, {CFrame = door.CFrame})

openPart.Touched:Connect(function(hit)
    if db and hit.Parent:FindFirstChild("Humanoid") then
        db = false
        open:Play() open.Completed:Wait() task.wait(1)
        close:Play() close.Completed:Wait() task.wait(0.5)
        db = true
        end
    end)
end
#

and the 3 is still doing an error for some reason

lofty venture
#

Not sure why the 3 has an error

#

But

odd gyro
#

ok it's not doing the error anymore

lofty venture
#

door.Parent.CellRoom:WaitForChild()

odd gyro
#

I just set the info like this

lofty venture
#

Oh yeah of course

#

When u set it the other way u have to do ;

odd gyro
#

Its

#

WORKING

#

it took 3 days for me to make a fricking working door

lofty venture
#

This would’ve been alot easier if I was at my computer lol

#

All good been there before

odd gyro
#
local openPart = script.Parent
local door = workspace.DoorPrimaryPart
local TweenService = game:GetService("TweenService")
local debounce = false


local tweenInfo = TweenInfo.new(
    3,
    Enum.EasingStyle.Exponential,
    Enum.EasingDirection.Out,
    0,
    false,
    0
)
local openDoor = {
    CFrame = door.CFrame + Vector3.new(0,0,4.75)
}

local closeDoor = {
    CFrame = door.CFrame + Vector3.new(0,0,0)
}
local tween1 = TweenService:Create(door, tweenInfo, openDoor)
local tween2 = TweenService:Create(door, tweenInfo, closeDoor)

openPart.Touched:Connect(function(hit)
    if debounce == false and hit.Parent:FindFirstChild("Humanoid") then
        tween1:Play()

        tween1.Completed:Wait()

        debounce = true
    end
end)

openPart.TouchEnded:Connect(function(hit)
    if debounce == true and hit.Parent:FindFirstChild("Humanoid") then
        if tween1.PlaybackState == Enum.PlaybackState.Playing then
            tween1:Cancel()
            tween2:Play()

            tween2.Completed:Wait()

            debounce = false
        end
    end
end)
#

the script looked like this before

#

but someone helped me improve it

#

I'm still a beginner at programming

odd gyro
lofty venture
#

Messy scripts always give me anxiety 😂

lofty venture
odd gyro
#

ty now I can sleep at peace it's 2AM

#

after 3 days for a door 🙏

#

good night :))

lofty venture
#

Lol gn

odd gyro
#

I can't open a door if one of them is already opening

lofty venture
#

Do u have a db system inside of the script?@odd gyro

odd gyro
#
local cs = game:GetService("CollectionService")
local doors = cs:GetTagged("DoorTag")
local ts = game:GetService("TweenService")
local db = true


for _,door in pairs(doors) do
local doorSound = door:WaitForChild("BuzzSound")
local openPart = door.Parent.CellRoom:WaitForChild("OpenPart")
local info = TweenInfo.new(3, Enum.EasingStyle.Exponential,Enum.EasingDirection.Out,0,false,0)

local open = ts:Create(door, info, {CFrame = door.CFrame + Vector3.new(0,0,4.72)})
local close = ts:Create(door, info, {CFrame = door.CFrame})

openPart.Touched:Connect(function(hit)
    if db and hit.Parent:FindFirstChild("Humanoid") then
        db = false
        doorSound.Playing = true
        open:Play() open.Completed:Wait()
        close:Play() close.Completed:Wait()
        db = true
        end
    end)
end
lofty venture
#

The fastest and less complicated way to fix this is by adding a bool value to the doors and using that to check if the player has touched the sensor within a certain amount of time

#

Kinda like a temporary lock 🔒

odd gyro
#

a

#

this is gonna be hard

lofty venture
#

I can edit the script for u

#

Give me a min

odd gyro
#

just explain me and I'll do it

#

I will learn how to do it this way

lofty venture
#

place this inside of the for i,v loop: local db = door:WaitForChild([Bool Value Name]).Value

#

this grabs the boolValue from every door

odd gyro
#

so I delete the other db ?

lofty venture
#

nah, just change the variable

odd gyro
#

ok

lofty venture
#

Or wait

odd gyro
#

done

lofty venture
#

lol

odd gyro
#

a

lofty venture
#

alright

odd gyro
#

tell me the other way if you want

lofty venture
#

I was gonna say, if its not to late try just putting the db varible you had at first inside the loop

odd gyro
#

local db = true ?

lofty venture
#

theroretically it might create a db for each door

#

yea

odd gyro
#

do I need the bool value anymore ?

lofty venture
#

no

odd gyro
#

alright

#

done

lofty venture
#

lmk if it still doesnt work

odd gyro
#

dang it was that easy

#

it worked

#

ty

lofty venture
#

of course

odd gyro
#

took me 5 days for doors that's crazy when you are a beginner at scripting

lofty venture
#

lol, been there, done that