Ad
Log in to vote
0

Is my if statement formatted incorrectly?

Asked by 2 months ago

I'm trying to get the CFrame code in the if statement to work. Outside of the if statement it works just fine and the print functions outputs true (Which is what should be happening when I click.) It's only until I try to make the code only run when both of the keyClicked variables are. I'm not sure if I'm formatting the if statement incorrectly or not because I also don't get any errors in the console. How could I fix this?

keyOne.ClickDetector.MouseClick:Connect(function()
    keyOneClicked = true
    keyOne.CFrame *= CFrame.Angles(math.rad(90), 0, 0)
    print(keyOneClicked)
    return keyOneClicked
end)

keyTwo.ClickDetector.MouseClick:Connect(function()
    keyTwoClicked = true
    keyTwo.CFrame *= CFrame.Angles(math.rad(-90),0 , 0)
    print(keyTwoClicked)
    return keyTwoClicked
end)


if keyOneClicked == true and keyTwoClicked == true then
    for i = 1, 10  do
        game.Workspace.StartupButton.Cap:SetPrimaryPartCFrame(hinge.CFrame*CFrame.Angles(math.rad(10), 0, 0))
        wait()
    end
else
    print("Didnt Work")
end
0
The if statement is only being checked once since it's not inside a loop or event. Try putting it inside a loop. xInfinityBear 1154 — 2mo
0
Thank You! typedkeyboard 0 — 2mo

Answer this question