If your script isn’t working in Roblox, there might be issues with the code, object setup, or connections. Here are some troubleshooting steps and a basic example of how to script a door that reacts when touched:
Basic Door Script Here’s an example script for a door that disappears when touched:
Make sure the door is a part and has the CanCollide property set to true (so it blocks players before the touch). Add a Script or LocalScript to the part.
local door = script.Parent -- Reference to the door part
local function onTouch(hit) -- Check if the object touching the door is a player local character = hit.Parent if character:FindFirstChild("Humanoid") then door.CanCollide = false -- Makes the door passable door.Transparency = 0.5 -- Makes the door semi-transparent wait(2) -- Wait for 2 seconds door.CanCollide = true -- Makes the door solid again door.Transparency = 0 -- Makes the door fully visible end end
door.Touched:Connect(onTouch) -- Connect the function to the Touched event