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

Script is not detecting a click?

Asked by 7 years ago

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.

0
Why r u using parenthesis for that? KingLoneCat 2642 — 7y
0
Also, you need to use '==' to compare two values. KingLoneCat 2642 — 7y

2 answers

Log in to vote
1
Answered by
caipira 29
7 years ago

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
Ad
Log in to vote
1
Answered by 7 years ago

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)

Answer this question