I'm a beginner so it is most likely very obvious.
if game.Workspace.Cheese.CanCollide == true then end script.Parent.MouseButton1Click:connect(function() game.Workspace.Cheese.CanCollide = false end) function numbertwo() game.Workspace.Cheese.CanCollide = true end if game.Workspace.Cheese.CanCollide == false then end script.Parent.MouseButton1Click:connect(function(numbertwo) game.Workspace.Cheese.CanCollide = true end)
The Opening Works, it's closing it that's the problem. Cheese = My door btw Can someone please tell me what I did wrong so I don't make this mistake in the future.
collide = true script.Parent.MouseButton1Click:connect(function() if collide == true then game.Workspace.Cheese.CanCollide = false collide = false else game.Workspace.Cheese.CanCollide = true collide = true end end)
If this doesn't work, tell me in the chat and I'll fix it.
Your problem is that you misplaces your function at the the end. It could be easier.
function openclose () local door= game.Workspace.Cheese if script.Parent.Text== "Open door" then --"Open door" is just a exampe, change it to whatever your button says. door.CanCollide= false script.Parent.Text="Close Door" -- Again "Close door" is just an example, change it however you want it. else if script.Parent.Text== "Close door" then door.CanCollide= true script.Parent.Text="Open door" -- change open door to the text you have in the beginning end end end script.Parent.MouseButton1Click:connect(openclose)
I wrote this all on mobile and havent tested this myself, there is a high possibility that i mistyped something. But in principle it has to work.