Object
发布时间:2026-09-17 | 浏览:1
For Agents | This page is available as markdown: https://create.roblox.com/docs/en-us/reference/engine/classes/Object.md | Documentation index: https://create.roblox.com/docs/llms.txt | Engine API index: https://create.roblox.com/docs/reference/engine/llms.txt Learn English Feedback Engine Class Object Not Creatable Not Replicated Summary Properties ClassName : string className : string Deprecated Methods GetPropertyChangedSignal ( property : string ) : RBXScriptSignal IsA ( className : string ) : boolean isA ( className : string ) : boolean Deprecated Events Changed ( property : string ) : RBXScriptSignal Inherited by Capture , ConfigSnapshot , EditableImage , EditableMesh , Instance , Show more... API Reference Properties ClassName Read Only Not Replicated Read Parallel Object.ClassName : string Code Samples Class Name for _, child in workspace :GetChildren() do if child.ClassName == "Part" then print ( "Found a Part" ) -- will find Parts in model, but NOT TrussParts, WedgeParts, etc end end Provide feedback className Deprecated Show details Methods GetPropertyChangedSignal Object:GetPropertyChangedSignal ( property : string ) : RBXScriptSignal Parameters property : string Returns RBXScriptSignal Code Samples Old-to-New Values with Changed local part = Instance.new( "Part" ) local currentColor = part.BrickColor local function onBrickColorChanged () local newColor = part.BrickColor print ( "Color changed from" , currentColor.Name, "to" , newColor.Name) currentColor = newColor end part:GetPropertyChangedSignal( "BrickColor" ):Connect(onBrickColorChanged) part.BrickColor = BrickColor.new( "Really red" ) part.BrickColor = BrickColor.new( "Really blue" ) Changed and GetPropertyChangedSignal local part = Instance.new( "Part" ) local function onBrickColorChanged () print ( "My color is now " .. part.BrickColor.Name) end local function onChanged (property) if property == "BrickColor" then onBrickColorChanged() end end part:GetPropertyChangedSignal( "BrickColor" ):Connect(onBrickColorChanged) part.Changed:Connect(onChanged) -- Trigger some changes (because we connected twice, -- both of these will cause two calls to onBrickColorChanged) part.BrickColor = BrickColor.new( "Really red" ) part.BrickColor = BrickColor.new( "Institutional white" ) Provide feedback IsA Write Parallel Object:IsA ( className : string ) : boolean Parameters className : string Returns boolean Code Samples Instance:IsA() local Workspace = game :GetService( "Workspace" ) print (Workspace:IsA( "Workspace" )) -- true print (Workspace:IsA( "BasePart" )) -- false print (Workspace:IsA( "Instance" )) -- true Provide feedback isA Deprecated Show details Events Changed Object.Changed ( property : string ) : RBXScriptSignal Parameters property : string Code Samples 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" Change Detector local object = script .Parent local function onChanged (property) -- Get the current value of the property local value = object[property] -- Print a message saying what changed print (object:GetFullName() .. "." .. property .. " (" .. typeof (value) .. ") changed to " .. tostring (value)) end object.Changed:Connect(onChanged) -- Trigger a simple change in the object (add an underscore to the name) object.Name = "_" .. object.Name Provide feedback Jump to ▼ Object Summary Properties Methods Events Properties ClassName className Methods GetPropertyChangedSignal() IsA() isA() Events Changed English Feedback ©2026 Roblox Corporation. Roblox, the Roblox logo and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries. Terms · Privacy · Accessibility · Support English