Files
Next_Station_Plugin/src/Toolbar/Buttons.ts

39 lines
1.2 KiB
TypeScript

const Selection = game.GetService("Selection");
const ChangeHistoryService = game.GetService("ChangeHistoryService");
export function createNewRoomButton(toolbar: PluginToolbar) {
const newRoomButton = toolbar.CreateButton("New Room", "New Room", "rbxassetid://14978048121");
newRoomButton.Click.Connect(function () {
const selectedObjects = Selection.Get();
if (selectedObjects.isEmpty()) return;
const room = selectedObjects[0];
if (!room.IsA("Model")) return;
const config = new Instance("Configuration");
config.Name = "RoomConfig";
config.Parent = room;
const origin = new Instance("Vector3Value");
origin.Name = "Origin";
origin.Parent = config;
origin.Value = room.GetPivot().Position;
const endvalue = new Instance("Vector3Value");
endvalue.Name = "End";
endvalue.Parent = config;
endvalue.Value = room.GetPivot().Position;
const roomtype = new Instance("StringValue");
roomtype.Name = "RoomType";
roomtype.Parent = config;
const roomId = new Instance("IntValue");
roomId.Name = "RoomId";
roomId.Parent = config;
ChangeHistoryService.SetWaypoint("Added new room config");
Selection.Set([]);
Selection.Set([room]);
});
}