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

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

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)

3 comments

0

part Isnt Defined

0

It should be Part = Script.Parent

0

does not have to be defined. It should work well.

2 answers

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)

1 comment

0

Oh thank you so much!

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....

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