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

Why isn't my door script working? I looked all over the script and couldn't find why!

Asked by 8 years ago

i looked everywhere and i cannot find the problem to why this wont work.

part.Touched:connect(function(hit)
script.Parent.Transparency = .1
wait(0.1)
script.Parent.Transparency = .2
wait(0.1)
script.Parent.Transparency = .3
wait(0.1)
script.Parent.Transparency = .4
wait(0.1)
script.Parent.Transparency = .5
wait(0.1)
script.Parent.CanCollide = false
wait(0.1)
script.Parent.Transparency = .6
wait(0.1)
script.Parent.Transparency = .7
wait(0.1)
script.Parent.Transparency = .8
wait(0.1)
script.Parent.Transparency = .9
wait(0.1)
script.Parent.Transparency = 1
wait(4)
script.Parent.Transparency = .9
wait(0.1)
script.Parent.Transparency = .8
wait(0.1)
script.Parent.Transparency = .7
wait(0.1)
script.Parent.Transparency = .6
wait(0.1)
script.Parent.Transparency = .5
wait(0.1)
script.Parent.ConCollide = true
wait(0.1)
script.Parent.Transparency = .4
wait(0.1)
script.Parent.Transparency = .3
wait(0.1)
script.Parent.Transparency = .2
wait(0.1)
script.Parent.Transparency = .1
wait(0.1)
script.Parent.Transparency = 0
end)
0
part Isnt Defined TayLife12 69 — 8y
0
It should be Part = Script.Parent TayLife12 69 — 8y
0
does not have to be defined. It should work well. FarisDinieGaming 20 — 8y

2 answers

Log in to vote
0
Answered by
H4X0MSYT 536 Moderation Voter
8 years ago

Maybe this will work? I have no clue but it should work. Also I cleaned it up a bit for you with loops... There's something even shorter with for i,v that stuff, but I'm still figuring it out myself.

local part = script.Parent
part.Touched:connect(function() -- Hit is not needed as you have not used it in the script
local transparency = 0
    while wait(0.1) do -- wait 0.1 at a time
        transparenecy = transparenecy + .1
        part.Transparency = transparency -- change parts transparenecy as the time goes on
        if transparency == .5 then -- as soon as its 0.5 transparency we open the door
            part.CanColide = false
        end
            if transparency == 1 then -- as soon as the transparency is 1 we start closing the door
                while wait(0.1) do
                    transparency = transparency - 0.1
                    if transparenecy == .5 then -- as soon as .5 transparency we close the door
                        part.CanColide = true
                    end
                    if transparency == 0 then break end -- break the loop
                end
            end
    break -- break the other look.
    end
end)
0
Oh thank you so much! Quackshire 17 — 8y
Ad
Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

Maybe this will work. My coding is basic though.

-- Variable --
part = script.Parent
isOpen = false

-- Main --
part.Touched:connect(function()

if isOpen == false then -- Checks if door is open

    isOpen = true -- Declare that door is open/opening

    for i = 0, .5, .1 do -- Fading
        part.Transparency = i
        wait(.1)
    end

    part.CanCollide = false -- Make players able to walk through
    wait (1)

    for i = .5, 0 , -.1 do -- Fading
        part.Transparency = i
        wait(.1)
    end

    isOpen = false -- Declare that door is closed
    part.CanCollide = true -- Players are now NOT able to walk through

end)

Might work idk....

Answer this question