|
| 21 Sep 2017 03:52 AM |
at the end of this script here, i want it to check if one out of gateTable(1, 2) is true for a different function and if they both aren't, different function. idk how to do it
--First Objective (Gate)
local gateTable = {false, false, false}
local keypart1 = game.Workspace.KeyTest1
keypart1.ClickDetector.MouseClick:connect(function(player) if not gateTable[1] then if not gateTable[2] then gateTable[1] = true print("Key1 has been picked up!") keypart1.KeyEvent:FireClient(player, 1) keypart1:Destroy() else gateTable[1] = true print("The key has been put together!") keypart1.KeyEvent:FireClient(player, 2) keypart1:Destroy() gateTable[3] = true end end end)
local keypart2 = game.Workspace.KeyTest2
keypart2.ClickDetector.MouseClick:connect(function(player) if not gateTable[2] then if not gateTable[1] then gateTable[2] = true print("Key2 has been picked up!") keypart2.KeyEvent:FireClient(player, 1) keypart2:Destroy() else gateTable[2] = true print("The key has been put together!") keypart2.KeyEvent:FireClient(player, 2) keypart2:Destroy() gateTable[3] = true end end end)
local gate = game.Workspace.GateTest
gate.ClickDetector.MouseClick:connect(function(player) if not gateTable[3] then end end) |
|
|
| Report Abuse |
|
|
| |
|
|
| 21 Sep 2017 05:37 AM |
that looks right
u just dont have the code for the third key
also u may want to look back at the first else statement; something doesnt look right
#code error("you're*") |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2017 05:53 AM |
| everything is coded right in this. and there is no code for a third key. gateTable[3] is set when the combination of ################ #### is made. i might just have to say screw it and do just an if statement for gateTable[3]. but i THOUGH there was a way to check two values at once. |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2017 05:54 AM |
| of the 2 unlocking devices |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2017 05:59 AM |
if gatetable[1] == true and gatetable[2] == true then
end
or it could be replaced with while but im not sure if u wanted that
#code error("you're*") |
|
|
| Report Abuse |
|
|
| |
|
|
| 21 Sep 2017 06:04 AM |
but would it work like this:
if not gateTable[1] and gateTable[2] == true then |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2017 06:07 AM |
actually, i just found out about the or operator lel
so would this work (and i'll test this too):
if gateTable[1] == true or gateTable ==true then --blah blah end
|
|
|
| Report Abuse |
|
|
|
| 21 Sep 2017 06:08 AM |
where would u be putting that statement?
cause if both gatetable 1 and 2 are true then gate3 should then be turned to true and the code inside should be executed
if those requirements arent met then nothing will happen regardless of the situation
#code error("you're*") |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2017 06:14 AM |
what happens is, if a key is not picked up. "The gate is locked!" if a key but not both keys are picked up(because keys could be picked up in diff order) "You're missing a key!" if both keys are picked up gateTable[3] is set to true and then "The gate is unlocked!"
not that hard to grasp |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2017 06:20 AM |
i suggest u revise the way u made the script
u dont need that third bool for gatetable 3, its completely pointless
if gatetable[1] == true and gatetable[2] == true then
elseif gatetable[1] == true and gatetable[2] == false then
elseif gatetable[1] == false and gatetable[2] == true then
elseif gatetable[1] == false and gatetable[2] == false then
end
if u have only two bool values, then theres only 4 possible combinations
honestly i dont believe this is the best way to do any of this but it works in this situation
#code error("you're*") |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2017 06:20 AM |
--This now works
local gateTable = {false, false, false}
local keypart1 = workspace.KeyTest1
keypart1.ClickDetector.MouseClick:Connect(function(player) if not gateTable[1] then if not gateTable[2] then gateTable[1] = true print("Key1 has been picked up!") keypart1.KeyEvent:FireClient(player, 1) keypart1:Destroy() else gateTable[1] = true print("The key has been put together!") keypart1.KeyEvent:FireClient(player, 2) keypart1:Destroy() gateTable[3] = true end end end)
local keypart2 = workspace.KeyTest2
keypart2.ClickDetector.MouseClick:Connect(function(player) if not gateTable[2] then if not gateTable[1] then gateTable[2] = true print("Key2 has been picked up!") keypart2.KeyEvent:FireClient(player, 1) keypart2:Destroy() else gateTable[2] = true print("The key has been put together!") keypart2.KeyEvent:FireClient(player, 2) keypart2:Destroy() gateTable[3] = true end end end)
local gate = workspace.GateTest
gate.ClickDetector.MouseClick:Connect(function(player) if not gateTable[3] then if gateTable[1] == true or gateTable[2] == true then print("You're missing a key part!") else print("The gate is locked!") end else print("The gate is unlocked!") end end) |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2017 06:23 AM |
| the main reason i make 3 values is for more organization. so then the bool value of gateTable[3] is only related to the gate. and then the keyparts to their respective bools |
|
|
| Report Abuse |
|
|