Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why isn't SetWaypoint working for my plugin?

Asked by 4 years ago
Edited 4 years ago

I made a simple plugin but SetWaypoint functionality doesn't seem to be working. Am I doing it wrong?

local ChangeHistoryService = game:GetService("ChangeHistoryService")
local Selection = game:GetService("Selection")
local toolbar = plugin:CreateToolbar("Z Fighter") 
local newScriptButton = toolbar:CreateButton("Resolve Z-Fighting", "", "rbxassetid://1507949215")


local function onButtonClicked()
    ChangeHistoryService:SetWaypoint("Before apply") 

    local selectedObjects = Selection:Get()
    if #selectedObjects > 0 then
        local firstSelection = selectedObjects[1]       
        for i, p in pairs(firstSelection:GetChildren()) do
            if p:isA("Part") and i%2 == 1 then
                p.Position = p.Position + Vector3.new(0,0.001,0)
            end
        end
    end

    ChangeHistoryService:SetWaypoint("After apply")
end
newScriptButton.Click:Connect(onButtonClicked)

Answer this question