007egleagent

roact7

Oct 14th, 2020
738
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local ReplicatedStorage = game:GetService("ReplicatedStorage") --replicatedStorage
  2. local Roact = require(game.ReplicatedStorage.Roact)
  3. local Otter = require(ReplicatedStorage.otter) --getting otter from RS
  4. local Button = Roact.Component:extend("Button")
  5. local settings = require(script.Parent:WaitForChild("SettingsUi"))
  6. local Players = game:GetService("Players") --getting player variable
  7. -- local settings = require(script.Parent:WaitForChild("SettingsUi"))
  8. local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
  9.  
  10. -- \\\\\ Creating motors and functions for the animation with otter /////
  11. function Button:init()
  12. -- \\\\\ Creating motors for the animation with otter /////
  13.     -- MOTOR 1
  14.     self.originalPosition = Otter.createGroupMotor({
  15.         x=0,
  16.         y=0,
  17.     })
  18.     self.animation, self.movingAnimation = Roact.createBinding({
  19.         x=0,
  20.         y=0,
  21.     })
  22.  
  23.     self.originalPosition:onStep(function(values)
  24.         self.movingAnimation(values)
  25.     end)
  26.  
  27. -- \\\\\ Creating function for the animation with otter /////
  28.     self.goDown = function(rbx)
  29.         print(rbx.Parent)
  30.         -- Roact.mount(settings,playerGui)
  31.         game.SoundService.buttonClick:Play()
  32.         self.originalPosition:setGoal({
  33.             y=Otter.spring(0.2,{frequency = 6}),
  34.         })
  35.         wait(0.16)
  36.         self.originalPosition:setGoal({
  37.             y=Otter.spring(0,{frequency = 6}),
  38.         })
  39.         return rbx
  40.     end
  41.  
  42.     self.goHalfwayDown = function()
  43.         game.SoundService.buttonHover:Play()
  44.         self.originalPosition:setGoal({
  45.             y=Otter.spring(0.1,{frequency = 6})
  46.         })
  47.     end
  48.  
  49.     self.goHalfwayUp = function()
  50.         self.originalPosition:setGoal({
  51.             y=Otter.spring(0,{frequency = 6})
  52.         })
  53.     end
  54. end
  55.  
  56. -- \\\\\ Rendering the butons below /////
  57. function Button:render()
  58.     return Roact.createElement("Frame", {
  59.         BackgroundTransparency = 1,
  60.         Size = UDim2.new(0.07, 0, 0.07, 0),
  61.         LayoutOrder = self.props.LayoutOrder,
  62.     }, {
  63.         button = Roact.createElement("ImageButton",{
  64.             Size = UDim2.fromScale(1, 1),
  65.             AnchorPoint = Vector2.new(1,1),
  66.             Image = self.props.Image,
  67.             SizeConstraint = "RelativeXX",
  68.             ScaleType = "Fit",
  69.             BackgroundTransparency = 1,
  70.             ZIndex = 2,
  71.  
  72.             Position = self.animation:map(function(values)
  73.                 return UDim2.new(values.x + 1.2, 0, values.y+1, 0)
  74.             end),
  75.  
  76.             [Roact.Event.Activated] = self.goDown,
  77.  
  78.             [Roact.Event.MouseEnter] = self.goHalfwayDown,
  79.                    
  80.             [Roact.Event.MouseLeave] = self.goHalfwayUp,
  81.             }),
  82.             background = Roact.createElement("ImageLabel",{
  83.                 AnchorPoint = Vector2.new(1,1),
  84.                 BackgroundTransparency = 1,
  85.                 ScaleType = "Fit",
  86.                 SizeConstraint = "RelativeXX",
  87.                 Image = "rbxassetid://5813846731",
  88.                 Size = UDim2.fromScale(1, 1),
  89.                 Active = true,
  90.                 Position = self.props.Position,
  91.             })
  92.         })
  93. end
  94. return Button
RAW Paste Data