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

What happens if you set a Value's Value to nil?

If I were to put this in a script:

script.Parent.StringValue.Value = nil

What would happen? Would the value change to ""? Would the script error?

1 answer

✓ Accepted answer

Depends on the type of value object.

Object Values become nil.

String Values become nil.

Bool Values become false.

Number Values become 0.

Int Values become 0.

CFrame Values error unless CFrame.new(nil) is used, if so they become 0, 0, 0.

Vector3 Values error unless Vector3.new(nil) is used, if so they become 0, 0, 0.

Color3 Values error unless Color3.new(nil) is used, if so they become 0, 0, 0.

BrickColor3 Values error unless BrickColor.new(Color3.new(nil)) is used, if so they become Really black.

Ray Values error unless Ray.new(nil) is used, if so they become {0, 0, 0}, {0, 0, 0}

4 comments

0

So in a StringValue, if I used string.len after setting the Value to nil, it would come up as 0?

0

Correct, because it has no length!

0

Fantastic, thanks for your help!

0

No problem :)

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