bommes

ROBLOX Morph script

Oct 25th, 2020
1,323
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local RS = game:GetService("RunService")
  2. local TS = game:GetService("TweenService")
  3. local CloseButton = script.Parent:WaitForChild("CloseButton")
  4. local Frame = script.Parent:WaitForChild("ScrollingFrame")
  5. local open = script.Parent.Parent:WaitForChild("SkinsButton"):WaitForChild("Open")
  6. local inf = TweenInfo.new(0.5,Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
  7. local Open = TS:Create(script.Parent, inf, {Position = UDim2.new(0.5 , 0, 0.5, 0)})
  8. local Close = TS:Create(script.Parent, inf, {Position = UDim2.new(0.5, 0, 1.4, 0)})
  9. local RankValue = require(game:GetService("ReplicatedStorage"):WaitForChild("RankValue"))
  10. CloseButton.Activated:Connect(function()open.Value=not open.Value end)
  11. open.Changed:Connect(function(val)
  12.     if val then
  13.         Open:Play()
  14.     else
  15.         Close:Play()
  16.     end
  17. end)
  18. local Bar = script.Parent:WaitForChild("Bar")
  19. local currentPg = Bar:WaitForChild("CurrentPage")
  20. local Pages = script.Parent:WaitForChild("ScrollingFrame")
  21. local buttons = {}
  22. wait()
  23. for _,v in next,script.Parent.ScrollingFrame:GetDescendants()do
  24.     if v:IsA('TextButton')then
  25.         local Division=v:FindFirstChild("Division")
  26.         local MinRank=v:FindFirstChild("MinRank")
  27.         if (Division and not game.Players.LocalPlayer:IsInGroup(Division.Value))or(MinRank and RankValue.CompareTo(game.Players.LocalPlayer:GetRoleInGroup(5430366), MinRank.Value)<0)then
  28.             v:Destroy()
  29.         else
  30.             local ViewPort=v:WaitForChild("ViewportFrame")
  31.             local morph=ViewPort:FindFirstChildWhichIsA("Model")
  32.             local Bar=v:WaitForChild("TextLabel")
  33.             local GFX=Bar:WaitForChild("UIGradient")
  34.             local Cam=Instance.new("Camera")
  35.             local currentPg=script.Parent:WaitForChild("Bar").CurrentPage
  36.             local bindingName=v.Name .. v.Parent.Name
  37.             Cam.CFrame = morph:GetPrimaryPartCFrame() * CFrame.Angles(0, math.pi, 0)
  38.             Cam.CFrame = Cam.CFrame - Cam.CFrame.LookVector * 5.5
  39.             ViewPort.CurrentCamera = Cam
  40.             local function rotate()
  41.                 morph:SetPrimaryPartCFrame(morph:GetPrimaryPartCFrame() * CFrame.fromEulerAnglesXYZ(0, math.rad(-1), 0))
  42.             end
  43.             v.Activated:Connect(function()
  44.                 game:GetService("ReplicatedStorage").ChangeMesh:FireServer(morph.Name)
  45.                 open.Value=not open.Value
  46.             end)
  47.             v.MouseEnter:Connect(function()
  48.                 TS:Create(GFX, inf, {Offset = Vector2.new(0, -1)}):Play()
  49.             end)
  50.  
  51.             v.MouseLeave:Connect(function()
  52.                 TS:Create(GFX, inf, {Offset = Vector2.new(0, 0)}):Play()
  53.             end)
  54.             open.Changed:Connect(function(val)
  55.                 if val and currentPg.Value.Name == v.Parent.Name then
  56.                     Cam.CFrame = morph:GetPrimaryPartCFrame() * CFrame.Angles(0, math.pi, 0)
  57.                     Cam.CFrame = Cam.CFrame - Cam.CFrame.LookVector * 5.5
  58.                     local success, message = pcall(function() RS:UnbindFromRenderStep(bindingName) end)
  59.                     RS:BindToRenderStep(bindingName, Enum.RenderPriority.Camera.Value, rotate)
  60.                 end
  61.             end)
  62.             currentPg.Changed:Connect(function(pg)
  63.                 if pg == currentPg.Parent:FindFirstChild(v.Parent.Name) then
  64.                     RS:BindToRenderStep(bindingName, Enum.RenderPriority.Camera.Value, rotate)
  65.                 else
  66.                     RS:UnbindFromRenderStep(bindingName)
  67.                     Cam.CFrame = morph:GetPrimaryPartCFrame() * CFrame.Angles(0, math.pi, 0)
  68.                     Cam.CFrame = Cam.CFrame - Cam.CFrame.LookVector * 5.5
  69.                 end
  70.             end)
  71.         end
  72.     end
  73. end
  74. for _, v in pairs(Bar:GetChildren()) do -- checks bind between buttons and pages
  75.     local page = Pages:FindFirstChild(v.Name)
  76.     if page then
  77.         if #page:GetChildren() > 0 then
  78.             table.insert(buttons, v)
  79.         else
  80.             page:Destroy()
  81.             v:Destroy()
  82.         end
  83.     end
  84. end
  85. Frame.CanvasSize = UDim2.new(#buttons, 0, 0, 0)
  86. table.sort(buttons, function(b1, b2)return b2.order.Value > b1.order.Value end)
  87. for i, v in pairs(buttons) do
  88.     v.Size = UDim2.new(1/#buttons, 0, 1, 0)
  89.     v.Position = UDim2.new((i-1)/#buttons, 0, 0, 0)
  90.     local page = Pages:FindFirstChild(v.Name)
  91.     page.Size = UDim2.new(1/#buttons, 0, 1, 0)
  92.     page.Position = UDim2.new((i-1)/#buttons, 0, 0, 0)
  93.     local GFX = v.UIGradient
  94.     local Darken = TS:Create(GFX, inf, {Offset = Vector2.new(0, 1)})
  95.     local unDarken = TS:Create(GFX, inf, {Offset = Vector2.new(0, 0)})
  96.     local Hover = TS:Create(v, inf, {BackgroundTransparency = 0})
  97.     local deHover = TS:Create(v, inf, {BackgroundTransparency = 0.25})
  98.     v.MouseEnter:Connect(function()
  99.         Hover:Play()
  100.         Darken:Play()
  101.     end)
  102.     v.MouseLeave:Connect(function()
  103.         if currentPg.Value ~= v then
  104.             deHover:Play()
  105.             unDarken:Play()
  106.         end
  107.     end)
  108.     v.Activated:Connect(function()
  109.         currentPg.Value = v
  110.     end)
  111.     currentPg.Changed:Connect(function(val)
  112.         if val == v then
  113.             Hover:Play()
  114.             Darken:Play()
  115.             TS:Create(Frame, inf, {CanvasPosition = Vector2.new((i-1) * Frame.AbsoluteSize.X, (i-1) * Frame.AbsoluteSize.Y)}):Play()
  116.         else
  117.             deHover:Play()
  118.             unDarken:Play()
  119.         end
  120.     end)
  121. end
  122. wait()
  123. currentPg.Value = buttons[1]
RAW Paste Data