What did I do wrong? I'm trying to make a textbox that on click it opens that make a part be able to go through and if you click it again it the part isn't able to go through? (CODE IN ANSWERS)
✓ ANSWER ACCEPTED
My textbox GUI door opener script isn't working? (MY CODE IN ANSWERS)
3 answers
✓ Accepted answer
Hey, I fixed up the script for you. Also, most importantly use a "Text Button" instead of a Text Box.
local button = script.Parent
local door = game.Workspace.Door
door.Anchored = true
button.MouseButton1Click:Connect(function()
if door.CanCollide == true then
door.CanCollide = false
elseif door.CanCollide == false then
door.CanCollide = true
end
end)
local Button = script.Parent
Door = game.workspace.Door
function onClick()
if Door.CanCollide == false then
Door.CanCollide == true
else Door.CanCollide == true then
Door.CanCollide == false
end
end
Button.MouseButton1Click:connect(OnClick)
local Button = script.Parent
local Door = game:GetService("Workspace"):WaitForChild("Door")
Door.Anchored = true
Button.MouseButton1Click:Connect(function()
if Door.CanCollide then
Door.CanCollide = not Door.CanCollide
elseif not Door.CanCollide then
Door.CanCollide = true
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
The code you provided in the answers wouldn't work with an actual game as you seem to be setting properties of a door in a local script, instead try making it so that when a player clicks the button, it fires a remote event that opens and closes the door