Attach
Import the Attach module from Weave:
1 2 | |
Weave provides an Attach function for updating any Instance.
Attach(ScreenGui.CoinDisplay.TextLabel) {
BackgroundColor3 = Color3.new(1, 1, 1),
BackgroundTransparency = 0,
}
✨ Value and Computed properties update automatically ✨
local coins = Value.new(1100000)
local coinDisplay = Computed.new(function()
return styleNumber(coins:get())
end)
Attach(ScreenGui.CoinDisplay.TextLabel) {
Text = coinDisplay,
}
coins:set(756000)
-- TextLabel.Text is now "75.6k"
Attach updates Instance properties automaticallyUsage¶
To use Attach:
- Call
Attachwith theInstanceyou want to update
Attach(Frame) -- TODO: Add Properties
- Define a table of properties:
Attach(Frame) {
Size = UDim2.new(1, 0, 1, 0),
}
Attach works on any Instance type and any Property
local brickColor = Value.new(BrickColor.Red())
Attach(workspace.Part) {
BrickColor = brickColor
}
local visible = Value.new(true)
Attach(ScreenGui.Frame) {
Visible = visible
}
local cameraType = Value.new(Enum.CameraType.Scriptable)
Attach(workspace.CurrentCamera) {
CameraType = cameraType
}
Instance Reuse¶
Attach returns the Instance back to you:
local textLabel = Attach(ScreenGui.TextLabel) {
Text = "Loading..."
}
print(textLabel.Text) --> Loading...