StringValue

사용되지 않는 항목 표시

*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.

StringValue는 단일 Luau 문자열을 저장하는 목적을 가진 개체입니다.문자열의 길이는 200,000자 이상일 수 없습니다(이로 인해 "문자열이 너무 길다" 오류가 발생함).모든 "-Value" 개체와 마찬가지로 이 단일 값은 값 속성에 저장됩니다.이것(그리고 이와 유사한 다른 개체)에 대한 변경된 이벤트는 속성이 변경되는 문자열 대신 개체에 저장된 새 값으로 발생합니다.

문자열이 속성 창의 값 필드에 표시되기에는 너무 길어서 쉼표(...)로 구분된 문자열 내용이 부분적으로 표시되는 경우.

코드 샘플

This sample demonstrates the subtleties of the Changed event on normal objects and "-Value" objects.

Changed Event

-- Demonstrate the Changed event by creating a Part
local part = Instance.new("Part")
part.Changed:Connect(print)
-- This fires Changed with "Transparency"
part.Transparency = 0.5
-- Similarly, this fires Changed with "Number"
part.Name = "SomePart"
-- Since changing BrickColor will also change other
-- properties at the same time, this line fires Changed
-- with "BrickColor", "Color3" and "Color3uint16".
part.BrickColor = BrickColor.Red()
-- A NumberValue holds a double-precision floating-point number
local vNumber = Instance.new("NumberValue")
vNumber.Changed:Connect(print)
-- This fires Changed with 123.456 (not "Value")
vNumber.Value = 123.456
-- This does not fire Changed
vNumber.Name = "SomeNumber"
-- A StringValue stores one string
local vString = Instance.new("StringValue")
vString.Changed:Connect(print)
-- This fires Changed with "Hello" (not "Value")
vString.Value = "Hello"

속성

Value

병렬 읽기

저장된 문자열.

메서드

이벤트

Changed

변경될 때마다 StringValue.ValueStringValue 가 발사됩니다.속성이 변경되는 문자열 대신 새 값이 인수 개체에 저장되어 실행됩니다. It will run with the new value being stored in the argument object, instead of a string representing the property being changed.

이 이벤트는 다른 변경된 이벤트와 마찬가지로 문자열 값이 변경될 때와 변경될 수 있는 다양한 값을 추적하는 데 사용할 수 있습니다.

예를 인스턴스, 문자열 값을 사용하여 NPC 또는 아이템 이름과 같은 값을 추적하는 게임에서 유용할 수 있습니다.

요구 사항에 가장 적합한 개체 유형에 따라 NumberValueBoolValue와 같은 유사한 개체에 대해 동등한 변경 이벤트가 존재합니다.

매개 변수

value: string

변경 후의 새 값.


코드 샘플

The below example, assuming all referenced objects existed, would print the StringValue's new value each time it changed. In the example below it would print "Hello world!".

How to Use StringValue.Changed

local value = Instance.new("StringValue")
value.Parent = workspace
value.Changed:Connect(function(NewValue)
print(NewValue)
end)
value.Value = "Hello world!"