I'm trying to make a door that when touched by the monster, will open. I have basically the main part of the script finished but to reduce the risk of the door breaking and sliding off into infinity, I want to somehow check if the monster has touched the door for more than 2 seconds. This is to prevent any random small touches of the door that only last for like a millisecond to open the door and break it. this is the monster touched part of the script:
local function monstergotit()
Open = true
script.Parent.Door["Open" .. math.random(1,3)]:Play()
spawn(function()
for i = 3,(Door.Size.z / 0.15) do
Door.CFrame = Door.CFrame - (Door.CFrame.lookVector * 0.15)
wait()
end
end)
spawn(function()
for i = 3,(Door2.Size.z / 0.15) do
Door2.CFrame = Door2.CFrame - (Door2.CFrame.lookVector * 0.15)
wait()
end
end)
end
local bool = true
script.Parent.Door.touched:connect(function(touch)
if touch:IsA("Part") and SCPTable[touch.Parent.Name] == true and bool == true then
bool = false
wait(5)
monstergotit()
wait(5)
bool = true
end
end)
script.Parent.Door2.touched:connect(function(touch)
if touch:IsA("Part") and SCPTable[touch.Parent.Name] == true and bool == true then
bool = false
wait(5)
monstergotit()
wait(5)
bool = true
end
end)
i would like to know how to insert something like that into this script, and have someone explain how it works so im not just mindlessly copy and pasting a line of code. Help would be helpful (obviously)
