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

Touched function not activating, and BoolValue is not a valid member??

local debounce = true

script.Parent.Touched:connect(function(Part)
if debounce == true then
debounce = false
local Staff = Part.BoolValue.Value
		if Part.Name == "Handle" and Staff == false then
		if Part.CardNumber.Value == script.Parent.RoomNumber.Value then
		script.Parent.Parent.Door.CanCollide = false
		script.Parent.Parent.Door.Transparency = 0.4
		wait(2)
		script.Parent.Parent.Door.CanCollide = true
		script.Parent.Parent.Door.Transparency = 0
		
		elseif Part.Name == "Handle" and Staff == true then
			script.Parent.Parent.Door.CanCollide = false
		script.Parent.Parent.Door.Transparency = 0.4
		wait(2)
		script.Parent.Parent.Door.CanCollide = true
		script.Parent.Parent.Door.Transparency = 0
		
end
		end	
		if debounce == false then
        debounce = true
		end
	
wait(0.2)
		end
	

end)

For some reason the touched function and BoolValue aren't working. But everything is there. How do I fix this? Help is greatly appreciated...

1 answer

✓ Accepted answer

Remember, anything can touch that part (or at least any other part). Because anything can make the event fire, the Part parameter can also equal anything. So when you write

local Staff = Part.BoolValue.Value

It may not exist in the specific part that made the event fire, thus throwing an error.

Use FindFirstChild make sure it exists before you use it.

local Staff = Part:FindFirstChild("BoolValue")
if Staff then

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