Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My textbox GUI door opener script isn't working? (MY CODE IN ANSWERS)

Asked by 5 years ago
Edited 5 years ago

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)

0
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 theking48989987 2147 — 5y

3 answers

Log in to vote
0
Answered by 5 years ago

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)
Ad
Log in to vote
0
Answered by 5 years ago
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)
Log in to vote
0
Answered by
Syclya 224 Moderation Voter
5 years ago
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)

Answer this question