StringValue
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
ตัวแปรสตริงเป็นวัตถุที่มีไว้เพื่อเก็บสตริง Lua เดียว สตริง Lua เดียว ความยาวของสตริงไม่สามารถเป็นมากกว่า 200,000 ตัวอักษร
หากตัวอักษรยาวเกินไปที่จะแสดงในฟิลด์มูลค่าภายในหน้าต่างของโปรไฟล์ มันจะแสดงเนื้อหาของตัวอักษรต่อไปด้วยเลขชุด (...)
ตัวอย่างโค้ด
This sample demonstrates the subtleties of the Changed event on normal objects and "-Value" objects.
-- 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"
สรุป
อีเวนต์
ยิงเมื่อใดก็ได้เมื่อ StringValue.Value เปลี่ยนแปลง
คุณสมบัติ
วิธีการ
อีเวนต์
Changed
จะดำเนินการทุกครั้งเมื่อ StringValue.Value ของ StringValue เปลี่ยนแปลง มันจะดำเนินการด้วยค่าใหม่ที่เก็บไว้ในตัวอาร์กิวเมนต์แทนที่จะเป็นสตริงที่แทนที่สถานะ
เหตุการณ์นี้เหมือนเหตุการณ์อื่น ๆ สามารถใช้เพื่อติดตามเมื่อ StringValue เปลี่ยนและติดตามค่าที่แตกต่างกันที่อาจเปลี่ยนแปลง
อินสแตนซ์StringValues เพื่อติดตามมูลค่าเช่น NPC หรือชื่อรายการ
มีเหตุการณ์ที่เทียบเท่ากันสำหรับวัตถุที่คล้ายคลึงกันเช่น NumberValue และ BoolValue ตามประเภทของวัตถุที่เหมาะกับความต้องการมากที่สุด
พารามิเตอร์
มูลค่าใหม่หลังการเปลี่ยนแปลง
ตัวอย่างโค้ด
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!".
local value = Instance.new("StringValue")
value.Parent = workspace
value.Changed:Connect(function(NewValue)
print(NewValue)
end)
value.Value = "Hello world!"