I'm using a click detector, so when a player touches a door, the door will have 1 transparency and wont be cancollide? my script is:
script.Parent.MouseButton1Click:connect(function(click) -- If the door is click do: script.Parent.Parent.Transparency = 1 -- Sets Transparency to 1 so its invisible script.Parent.Parent.CanCollide = false -- Sets CanCollide to false so its gothrough wait(5) -- Door will open for 5 seconds script.Parent.Parent.CanCollide = true -- Set CanCollide back to true script.Parent.Parent.Transparency = 0 -- Change the transparency back to 0 if script.Parent.Parent.CanCollide == false then -- If CanCollide is false then script.Parent.Parent.CanCollide = true -- Set CanCollide to true if its at false else -- If CanCollide was true already print("CanCollide part works") -- This is what "game" says if the CanCollide part of the script works. wait(0.1) -- Wait 0.1 seconds if script.Parent.Parent.Transparency == 1 then -- If its at 1 then script.Parent.Parent.Transparency = 0 -- Set it to 0 if its at 1 else -- If the transparency was 0 already print("Both parts work, Script works") -- This is what "game" says after it checks the Transparency end -- Ends the first "if" end -- Ends the seconds "if" end) -- Ends the whole script
NOTE: If you know, please just dont ignore this, give all what you've got.
Simplier version:
script.Parent.MouseButton1Click:connect(function(click) -- If the door is click do: script.Parent.Parent.Transparency = 1 -- Sets Transparency to 1 so its invisible script.Parent.Parent.CanCollide = false -- Sets CanCollide to false so its gothrough wait(5) -- Door will open for 5 seconds script.Parent.Parent.CanCollide = true -- Set CanCollide back to true script.Parent.Parent.Transparency = 0 -- Change the transparency back to 0 end
Once again, your error was very very small. "MouseButton1Click" is not a proper event for a ClickDetector. Instead, you use "MouseClick" for ClickDetectors.
I've shortened the script for you also.
debounce = false script.Parent.MouseClick:connect(function(click) if debounce == false then debounce = true script.Parent.Parent.Transparency = 1 script.Parent.Parent.CanCollide = false wait(5) script.Parent.Parent.CanCollide = true script.Parent.Parent.Transparency = 0 debounce = false elseif debounce == true then script.Parent.Parent.CanCollide = true script.Parent.Parent.Transparency = 0 debounce = false end end)
I think you need to inset a ClickDetector into the door, if you haven't already :)
What are you trying to do? Make the door transparent and cancollide if the brick is clicked??
Your script is way more coded then it needs to be
function Click() script.Parent.Parent.Door.CanCollide = false script.Parent.Parent.Door.Transparency = 1 wait(5) script.Parent.Parent.Door.CanCollide = true script.Parent.Parent.Door.Transparency = 0 end script.Parent.MouseButton1Click:connect(Click)