Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I have a problem with a door script that goes in clickdetector, how to fix this?

I am a beginner scripter and I am trying to make a simple open and close door that changes the transparency and cancollide when clicked and changes it back to default when clicked again. I need help on this script

game.Workspace.Part.CanCollide(function(close) close = true end)

local clickdetector = game.Workspace.Part.ClickDetector clickdetector.MouseClick:Connect(function() game.Workspace.Part.Transparency = (0.5) game.Workspace.Part.CanCollide = false close = false end) if close(false) then clickdetector.MouseClick:Connect(function() game.Workspace.Part.Transparency = (0) game.Workspace.Part.CanCollide = true end) end

the scripts error: 20:39:08.891 - Workspace.Part.ClickDetector.Script:1: attempt to call field 'CanCollide' (a boolean value)

if anyone could help me that would be great.

1 answer

Try this in the script

local clickDetector = script.Parent.ClickDetector
clickDetector.MouseClick:Connect(function()
    if script.Parent.Transparency == 0 then
        script.Parent.Transparency = .5
        script.Parent.CanCollide = false
    else
        script.Parent.Transparency = 0
        script.Parent.CanCollide = true
    end
end)

What this does is... When you click the door it will check to see if it is open, if it is then it will close it. If it isn't then it will open it

This discussion is preserved as it was. New answers, comments, and votes are closed.