Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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!

1 comment

0

btw its a bool value

1 answer

✓ Accepted answer

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.

2 comments

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"

0

huh, it works... thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.