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

Why won't this script work?

Asked by 10 years ago

My script doesn't seem to work properly.

brick = script.Parent.brick
c = true

function OnC()
    if c == true then
        c = false
        brick.CFrame = CFrame.new(-39.2, 4.69, -53.3)
    else
        brick.CFrame = CFrame.new(-39.2, 4.69, -46.8)
        c = false

    end
end

brick.ClickDetector.MouseClick:connect(OnC)

When I click my door, it rotates 90 degrees. When I click it again, it goes back. When I attempt to click one last time, it does not do anything. The script breaks after that.

2 answers

Log in to vote
0
Answered by 10 years ago

I see one error that I think is wrong. Since 'c' is acting as a debounce at the end you forgot to change it back to true. So line 10 should be like this:

c = true 
Ad
Log in to vote
0
Answered by
HexC3D 830 Moderation Voter
10 years ago
brick = script.Parent.brick
c = true
b = 0
function OnC()
    if c == true then
     brick.CFrame = CFrame.new(-39.2, 4.69, -53.3)
b = 1
c = false
end

if b == 1 then
        brick.CFrame = CFrame.new(-39.2, 4.69, -46.8)

c = true
b = 0
  end


end

brick.ClickDetector.MouseClick:connect(OnC)

0
What exactly does "b = 0" mean? killerthedemon 14 — 10y
0
Variable should work. HexC3D 830 — 10y

Answer this question