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

Script is not detecting a click?

Hello, I am new to Lua, i'm attempting to make a door which you click to walk through. I don't know whats wrong with the code.

if clicked = (true)
	then Game.Workspace.Door.CanCollide = (false)
end

Please help.

2 comments

0

Why r u using parenthesis for that?

0

Also, you need to use '==' to compare two values.

2 answers

You need put a click detector on the button and the script inside it, and do something like that

local button = script.Parent

button.ClickDetector.MouseClick:Connect(function()
game.workspace.Door.CanCollide = false

You need to use a ClickDetector. I modified the example on the Wiki page to fit your door.

local clickDetector = Instance.new("ClickDetector")
local function onMouseClick(player)
    game.Workspace.Door.CanCollide = false
end
clickDetector.Parent = game.Workspace.Door 
clickDetector.MouseClick:connect(onMouseClick)

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