PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

SetWaypoint

Sets a new waypoint which can be used as an undo or redo point.

Parameters

Name Type Default Description

Returns

Return Type Summary

Code Samples


ChangeHistoryService:SetWaypoint

In order for the waypoints to work correctly, you need to set one both before AND after you perform the action that should be able to be undone.

local ChangeHistoryService = game:GetService("ChangeHistoryService")
local Selection = game:GetService("Selection")

local toolbar = plugin:CreateToolbar("Example Plugin")
local button = toolbar:CreateButton("Neon it up", "", "")

button.Click:Connect(function()
    local parts = {}
    for _,part in pairs(Selection:Get()) do
        if part:IsA("BasePart") then
            parts[#parts+1] = part
        end
    end

    if #parts > 0 then
        ChangeHistoryService:SetWaypoint("Setting selection to neon")
        for _,part in pairs(parts) do
            part.Material = Enum.Material.Neon
        end
        ChangeHistoryService:SetWaypoint("Set selection to neon")
    end
end