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

How to open and close a door using a textButton?

Asked by
ssieej 7
2 years ago

I am trying to make an army game and I am wondering if someone can help me make a parts collision turn off when I click a textbutton.

0
client sided or server sided? User#32519 0 — 2y
0
tbh I don't know because I don't know a lot about scripting. ssieej 7 — 2y
0
client sided is just on the client and server sided is for everyone User#32519 0 — 2y
0
oh so server sided means it will basically happen for everyone and not just one person? If so then server sided. ssieej 7 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

Get the name of the part you want, Make a "ScreenGui", Insert a "Frame" into it, Go to the frame's properties and make it's background transparency 1, Insert a button into it, Add a script inside the button, Here is the code for that script:

local Debounce = false

script.Parent.MouseButton1Click:Connect(function()
    if Debounce == false then
        Debounce = true
        workspace.Part.CanCollide = false -- Replace "workspace.Part" with whatever name you have for your door.
        workspace.Part.Transparency = 0.3 -- Same here.
        print("Door opened")
    elseif Debounce == true then
        Debounce = false
        workspace.Part.CanCollide = true -- Same here too lol.
        workspace.Part.Transparency = 0 -- You know the drill lol.
        print("Door closed")

    end

end)

Comment down on this answer if you want the button to be a click detector instead.

0
Thank you so much! ssieej 7 — 2y
0
No problem! yayaheyman 90 — 2y
Ad

Answer this question