Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make this work more than once?

Apparently this only works once. Im not sure why

enabled = true

function onTouched(hit)
	local door1=script.Parent.Parent.Door1
	local door2=script.Parent.Parent.Door2
h = hit.Parent:FindFirstChild("Humanoid")
if h ~= nil then
if not enabled then return end
enabled = false
door1.CanCollide=false
door2.CanCollide=false
for i=1,10 do
	wait()

door1.Transparency=door1.Transparency+.1
door2.Transparency=door2.Transparency+.1



end
wait(4)
for i=1,20 do
	wait()

door1.Transparency=door1.Transparency-.1
door2.Transparency=door2.Transparency-.1


end
door1.CanCollide=true
door2.CanCollide=true
enabled = true
end
end

connection = script.Parent.Touched:connect(onTouched)

3 comments

0

Does it work?

0

Try it again

0

Fixed it.

2 answers

✓ Accepted answer
val = 0
time = 0
function onTouched(hit)
    local door1=script.Parent.Parent.Door1
    local door2=script.Parent.Parent.Door2
h = hit.Parent:FindFirstChild("Humanoid")
if h ~= nil then
val = 1
if val == 1 then
val = 0
door1.CanCollide=false
door2.CanCollide=false
for i=1,10 do
    wait()

door1.Transparency=door1.Transparency+.1
door2.Transparency=door2.Transparency+.1



end
wait(4)
for i=1,10 do
    wait()

door1.Transparency=door1.Transparency-.1
door2.Transparency=door2.Transparency-.1


end
door1.CanCollide=true
door2.CanCollide=true
end
end
end



script.Parent.Touched:connect(onTouched)

You don't need enabled though tell in the comments if it works.

+1 if helped.

17 comments

0

The enabled is debounce..

0

But, it still should work. I don't use debounce honestly.

0

But its on touch, so it will freak out or somthing?

0

Oh you mean so if some one touches it more then once.

0

Yeah it breaks..

0

As in, after a few times, it doesnt work

0

But try again

0

It works, but still after a while it stops working?

0

How many times.

0

It works 2 times, then stops working.

0

I tested your debounce with a "print" and it doesnt work.

0

Try again please sorry for the inconvenience

0

no problem! I upped your post btw.

0

Thanks :)

0

Oh! I checked in game, and it keeps subtracting the 0.1 from it, after the second time for some reason

0

I FIGURED IT OUT !!!

0

Thankyeverymuch

Have you tried the loop or wait?

wait(2) --if a function but the function there ex: Fire()
fire()
end

This discussion is preserved as it was. New answers, comments, and votes are closed.