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

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

Asked by
Discern 1007 Moderation Voter
9 years ago

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

Log in to vote
9
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
9 years ago

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}

0
So in a StringValue, if I used string.len after setting the Value to nil, it would come up as 0? Discern 1007 — 9y
0
Correct, because it has no length! BlackJPI 2658 — 9y
0
Fantastic, thanks for your help! Discern 1007 — 9y
0
No problem :) BlackJPI 2658 — 9y
Ad

Answer this question