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)
Hey, I fixed up the script for you. Also, most importantly use a "Text Button" instead of a Text Box.
01 | local button = script.Parent |
02 | local door = game.Workspace.Door |
03 |
04 | door.Anchored = true |
05 |
06 | button.MouseButton 1 Click:Connect( function () |
07 | if door.CanCollide = = true then |
08 | door.CanCollide = false |
09 | elseif door.CanCollide = = false then |
10 | door.CanCollide = true |
11 | end |
12 | end ) |
01 | local Button = script.Parent |
02 | Door = game.workspace.Door |
03 |
04 | function onClick() |
05 | if Door.CanCollide = = false then |
06 | Door.CanCollide = = true |
07 | else Door.CanCollide = = true then |
08 | Door.CanCollide = = false |
09 |
10 | end |
11 | end |
12 |
13 | Button.MouseButton 1 Click:connect(OnClick) |
01 | local Button = script.Parent |
02 | local Door = game:GetService( "Workspace" ):WaitForChild( "Door" ) |
03 | Door.Anchored = true |
04 |
05 | Button.MouseButton 1 Click:Connect( function () |
06 | if Door.CanCollide then |
07 | Door.CanCollide = not Door.CanCollide |
08 | elseif not Door.CanCollide then |
09 | Door.CanCollide = true |
10 | end |
11 | end ) |