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

How do I make this work more than once?

Asked by 11 years ago

Apparently this only works once. Im not sure why

01enabled = true
02 
03function onTouched(hit)
04    local door1=script.Parent.Parent.Door1
05    local door2=script.Parent.Parent.Door2
06h = hit.Parent:FindFirstChild("Humanoid")
07if h ~= nil then
08if not enabled then return end
09enabled = false
10door1.CanCollide=false
11door2.CanCollide=false
12for i=1,10 do
13    wait()
14 
15door1.Transparency=door1.Transparency+.1
View all 36 lines...
0
Does it work? HexC3D 830 — 11y
0
Try it again HexC3D 830 — 11y
0
Fixed it. HexC3D 830 — 11y

2 answers

Log in to vote
2
Answered by
HexC3D 830 Moderation Voter
11 years ago
01val = 0
02time = 0
03function onTouched(hit)
04    local door1=script.Parent.Parent.Door1
05    local door2=script.Parent.Parent.Door2
06h = hit.Parent:FindFirstChild("Humanoid")
07if h ~= nil then
08val = 1
09if val == 1 then
10val = 0
11door1.CanCollide=false
12door2.CanCollide=false
13for i=1,10 do
14    wait()
15 
View all 39 lines...

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

+1 if helped.

0
The enabled is debounce.. Tempestatem 884 — 11y
0
But, it still should work. I don't use debounce honestly. HexC3D 830 — 11y
0
But its on touch, so it will freak out or somthing? Tempestatem 884 — 11y
0
Oh you mean so if some one touches it more then once. HexC3D 830 — 11y
View all comments (13 more)
0
Yeah it breaks.. Tempestatem 884 — 11y
0
As in, after a few times, it doesnt work Tempestatem 884 — 11y
0
But try again HexC3D 830 — 11y
0
It works, but still after a while it stops working? Tempestatem 884 — 11y
0
How many times. HexC3D 830 — 11y
0
It works 2 times, then stops working. Tempestatem 884 — 11y
0
I tested your debounce with a "print" and it doesnt work. Tempestatem 884 — 11y
0
Try again please sorry for the inconvenience HexC3D 830 — 11y
0
no problem! I upped your post btw. Tempestatem 884 — 11y
0
Thanks :) HexC3D 830 — 11y
0
Oh! I checked in game, and it keeps subtracting the 0.1 from it, after the second time for some reason Tempestatem 884 — 11y
0
I FIGURED IT OUT !!! HexC3D 830 — 11y
0
Thankyeverymuch Tempestatem 884 — 11y
Ad
Log in to vote
-1
Answered by
foxy83 15
11 years ago

Have you tried the loop or wait?

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

Answer this question