StringValue

非推奨を表示

*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。

StringValue は、 Lua 文字列 を保存するための単一のオブジェクトです。ストリングの長さは 200,000 文字を超えることはできません (これは「文字列が長すぎる」エラーを引き起こします)。Like all "-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

Class.StringValue.Value の StringValue が変更されると、その新しい値が引数オブジェクトで実行され、プロパティが変更されていることを表すストリングではなく、変更後の新しい値が引数オブジェクトに格納されます。

このイベントは、他の変更されたイベントと同じように、StringValue が変更されたときに追跡し、変更された値を追跡します。

たとえば、これは NPC やアイテム名などの値を追跡するために StringValues を使用するゲームで便利に使用できます。

同様のオブジェクトには、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!"