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

Why Wont Value Turns False in scripts and manual check but does in output?

Asked by 4 years ago

I have this part of my amazing code--->

can = p.Backpack.can.Value

    if can == true then
print(can)
    can = false
print(can)
--bunch of stuff you must not know about ;(

and this is in a normal script in workspace... My problem is before i test the game, i set the value to true, i check and its true while playing game, and when the script fires. sure enough- the output says true, but then the can=false fires then the output fires and says "false", which means it just worked, but i manually check the value that is in player's backpack and i see its still true, then i press Q again (whole thing is executed by clicking button Q) and this whole thing fires like it was true, but the output says false, but manually checked and it said false, and s=the script acts like its false, i dont get it, please help! thanks

Cover: Scripts acts like can = TRUE Manual Check Shows can = TRUE Output tells me can = FALSE

plz halp fast!

0
btw its a bool value CommanderCaubunsia 126 — 4y

1 answer

Log in to vote
2
Answered by 4 years ago

I found the problem. You shouldn't use:

can = p.Backpack.can.Value

instead, you would do this:

can = p.Backpack.can

In the end, the code would look something like this.

can = p.Backpack.can

    if can.Value == true then
print(can)
    can.Value = false
print(can)
--The rest of your script here.
0
+1. To explain why: When you say "can = p.Backpack.can.Value", the variable "can" now refers to whatever "can.Value" is -- ex "true" or "false". If p.Backpack.can.Value later changes, it's not linked to the variable "can". Saying "can = p.Backpack.can" means that you can now access the up-to-date value with "can.Value" chess123mate 5873 — 4y
0
huh, it works... thanks CommanderCaubunsia 126 — 4y
Ad

Answer this question