NumberValue
非推奨を表示
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
NumberValue は、Lua 数値 を定義して、ダブル精度の浮動小数 、またはより一般的に ダブ
すべての「-Value」オブジェクトと同様、この単一の値は「Value」プロパティに格納されます。変更されたイベントは、「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"
概要
イベント
Class.NumberValue.Value が変更されるときに発動します。
プロパティ
方法
イベント
Changed
このイベントは、NumberValue.Value プロパティが変更されるときに発動します。
このイベントは、他の変更されたイベントと同じように、NumberValue が変更されたときに追跡し、変更された値を追跡します。
たとえば、これは、アイテム ID など、ゲーム状態と値を追跡するために NumberValues を使用するゲームでも便利です。
同様のオブジェクトには、ObjectValue やStringValue など、要件に最適なオブジェクトタイプがあります。
パラメータ
変更後の値。
コードサンプル
This example prints the NumberValue's new value each time it changes. Here it prints 20.
NumberValue Changed
local numberValue = script.Parent.NumberValue
local function printValue(value)
print(value)
end
numberValue.Changed:Connect(printValue)
numberValue.Value = 20