Requesting help

I was doing my casual work for my new game when I encountered this annoying problem.


string value

As you can see, I have set my string value to nothing so I am expecting that the word “Bye” will be printed in the output message.Nonetheless, neither “Bye” word nor any related warning or error is printed in the output message.At that moment, I was confused and dumbfounded.

I have tried several solution like changing the double equal into ~= and adding another else statement down there.The code is as shown below:

If game.Workspace.OwnValue.Value ~= nil then
       print ("Bye")
else print ("Hi")

end

This solution somehow worked yet I didn’t use it as I want to keep my script as short as possible.Hence, I would like to request for some help to solve this problem.Thank you very much :smiling_face_with_three_hearts:

1 Like

its actually

if game.Workspace.OwnValue.Value == "" then
print("bye")
end

From what I know you can’t set a StringValue to nil

I suggest you using a

if game.Workspace.OwnValue.Value == "" then
 -- Input code
end

thats kind of a legit copy of mine…

I apologize. I didn’t see your post till I hit enter.

its ok

Summary

What does “” actually mean?And is there any difference between nil and “”?

Sorry for asking so many question. I’m new to scripting and development :upside_down_face:

its basically a string of nothingness

"" Basically means its blank but not nil from what I know.

its nothing really too major lol

hey but did the script work though?

Fine but why object value works fine with nil? I just rewatch a tycoon tutorial and it used object value.

because it has no instance inside the value

but the string value has a blank string though so its not nil

Because the object nothing or not there. Its like giving a path and it not existing. The path is nil

So string value is blank but not nothing?

Correct. If you wanna say that.

yes you are correct

Summary

Thank both of you guys so much.I’ll try my best to make my new game work.

I wish you the best and good luck!