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

How do you make a door that when closed kills, but when opened allows you to pass?

I'm trying to make a laser door, but I can't figure out how to. My script won't even open the door, and the door won't even kill you. So thanks if you can help.

local isOn = true
local Brick = script.Parent
local kill = true

function on()
 isOn = true
 script.Parent.Transparency = .8
 script.Parent.CanCollide = true
if kill == true then
	local function PlayerTouched(Part)
	local Parent = Part.Parent
	if game.Players:GetPlayerFromCharacter(Parent) then
		Parent.Humanoid.Health = 0
	end
end
end

function off()
 isOn = false
kill = false
if kill == false then
script.Parent.Transparency = 1
 script.Parent.CanCollide = false
end

function onClicked()

 if isOn == true then off() else on() end

end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

on()

Im a bit of a noob, so please go easy on me! :)

1 answer

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