Advertisement
Guest User

AnchorPoint plugin

a guest
Jan 17th, 2018
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.00 KB | None | 0 0
  1. --//Variables
  2. local CoreGui = game:GetService("CoreGui")
  3. local RunService = game:GetService("RunService")
  4. local AnchorPoint = Vector2.new(0.5, 0.5)
  5. local Added = {}
  6. local AmountAdded = 0
  7. local Active = false
  8. local DescendantAdded
  9. local SavedActive = plugin:GetSetting("DefaultAnchorPoint_Plugin")
  10.  
  11. if RunService:IsRunMode() then return end
  12.  
  13. wait(1)
  14.  
  15. --//Easier Updates
  16. NewUpdate = Instance.new("StringValue")
  17. NewUpdate.Name = "NewUpdate"
  18. NewUpdate.Value = "DefaultAnchorPoint_Plugin"
  19. NewUpdate.Parent = RunService
  20.  
  21. --//DescendantAdded/DescendantRemoved
  22. function Enable()
  23.     DescendantAdded = game.DescendantAdded:connect(function(Child)
  24.         if Child:IsDescendantOf(CoreGui) then return end
  25.         if (Child:IsA("GuiObject") and (not Added[Child])) then
  26.             Added[Child] = {true}
  27.             Child.AnchorPoint = AnchorPoint
  28.         end
  29.     end)
  30. end
  31.  
  32. game.CoreGui.ChildAdded:connect(function(Child)
  33.     if Child.Name == "NewUpdate" and Child.Parent == RunService and Child.Value == "DefaultAnchorPoint_Plugin" then --Validation checks for update
  34.         DescendantAdded:Disconnect() --Stops code being messed up in new updates
  35.     end
  36. end)
  37. NewUpdate:Destroy()
  38.  
  39. local ToolBar = plugin:CreateToolbar("MiddleAnchorPoint")
  40. local Toggle = ToolBar:CreateButton("Middle AnchorPoint", "Toggle feature", "http://www.roblox.com/asset/?id=132402257")
  41. Toggle.Click:connect(function() --Toggle
  42.     if Active ~= false then
  43.         plugin:Activate(false)
  44.         Toggle:SetActive(false)
  45.         if DescendantAdded ~= nil then DescendantAdded:Disconnect() end
  46.         Active = false
  47.         plugin:SetSetting("DefaultAnchorPoint_Plugin", false)
  48.     elseif Active ~= true then
  49.         plugin:Activate(true)
  50.         Toggle:SetActive(true)
  51.         Enable()
  52.         Active = true
  53.         plugin:SetSetting("DefaultAnchorPoint_Plugin", true)
  54.     end
  55. end)
  56.  
  57. --//Save active setting | Save some time
  58. if SavedActive == nil or SavedActive == true then
  59.     plugin:Activate(true)
  60.     Toggle:SetActive(true)
  61.     Enable()
  62.     Active = true
  63.     if SavedActive == nil then
  64.         plugin:SetSetting("DefaultAnchorPoint_Plugin", true)
  65.     end
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement