generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: ### ### based system

Previous Thread :: Next Thread 
ISeeYourPost is not online. ISeeYourPost
Joined: 10 Jun 2013
Total Posts: 1815
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
ISeeYourPost is not online. ISeeYourPost
Joined: 10 Jun 2013
Total Posts: 1815
21 Sep 2017 05:33 AM
bump
Report Abuse
gohan31865 is not online. gohan31865
Joined: 30 Jan 2011
Total Posts: 895
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
ISeeYourPost is not online. ISeeYourPost
Joined: 10 Jun 2013
Total Posts: 1815
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
ISeeYourPost is not online. ISeeYourPost
Joined: 10 Jun 2013
Total Posts: 1815
21 Sep 2017 05:54 AM
of the 2 unlocking devices
Report Abuse
gohan31865 is not online. gohan31865
Joined: 30 Jan 2011
Total Posts: 895
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
ISeeYourPost is not online. ISeeYourPost
Joined: 10 Jun 2013
Total Posts: 1815
21 Sep 2017 06:02 AM
nnnooooooo no while loops
Report Abuse
ISeeYourPost is not online. ISeeYourPost
Joined: 10 Jun 2013
Total Posts: 1815
21 Sep 2017 06:04 AM
but would it work like this:

if not gateTable[1] and gateTable[2] == true then
Report Abuse
ISeeYourPost is not online. ISeeYourPost
Joined: 10 Jun 2013
Total Posts: 1815
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
gohan31865 is not online. gohan31865
Joined: 30 Jan 2011
Total Posts: 895
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
ISeeYourPost is not online. ISeeYourPost
Joined: 10 Jun 2013
Total Posts: 1815
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
gohan31865 is not online. gohan31865
Joined: 30 Jan 2011
Total Posts: 895
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
ISeeYourPost is not online. ISeeYourPost
Joined: 10 Jun 2013
Total Posts: 1815
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
ISeeYourPost is not online. ISeeYourPost
Joined: 10 Jun 2013
Total Posts: 1815
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image