I pretty much need this script to find my other backpack UI
-- Compiled with roblox-ts v1.2.7
local TS = require(game:GetService("ReplicatedStorage"):WaitForChild("AMS-rbxts_include"):WaitForChild("RuntimeLib"))
local Roact = TS.import(script, TS.getModule(script, "@rbxts", "roact").src)
local _flipper = TS.import(script, TS.getModule(script, "@rbxts", "flipper").src)
local Instant = _flipper.Instant
local Spring = _flipper.Spring
local _FlipperUtil = TS.import(script, script.Parent, "FlipperUtil")
local UseGroupFlipper = _FlipperUtil.UseGroupFlipper
local UseSingleFlipper = _FlipperUtil.UseSingleFlipper
local Janitor = TS.import(script, TS.getModule(script, "@rbxts", "janitor").src).Janitor
local Events = TS.import(script, script.Parent.Parent, "events").Events
local UserInputService = TS.import(script, TS.getModule(script, "@rbxts", "services")).UserInputService
local params = {
dampingRatio = 0.7,
frequency = 4,
}
local Numerals = { "I", "II", "III", "IV", "V", "VI", "VII", "IIX", "IX" }
local function handleTransparency(transp)
return function(val)
local diff = 1 - transp
return (1 - val) * diff + transp
end
end
local Toolbox
do
Toolbox = Roact.Component:extend("Toolbox")
function Toolbox:init(props)
self.janitor = Janitor.new()
self.status = false
self.Name = Roact.createRef()
self.ViewportFrame = Roact.createRef()
local _binding = UseGroupFlipper({
X = 0.107,
Y = 0.094,
})
self.posMotor = _binding[1]
self.posBinding = _binding[2]
self.posSetBinding = _binding[3]
local _binding_1 = UseSingleFlipper(0)
self.enabledMotor = _binding_1[1]
self.enabledBinding = _binding_1[2]
self.enabledSetBinding = _binding_1[3]
local _binding_2 = UseSingleFlipper(1)
self.visibleMotor = _binding_2[1]
self.visibleBinding = _binding_2[2]
self.visibleSetBinding = _binding_2[3]
end
function Toolbox:didUpdate()
self.status = self.props.status
self:UpdateEnabled()
end
function Toolbox:didMount()
self.status = self.props.status
self:UpdateEnabled()
self.janitor:Add(Events.ToolToggled:connect(function(id, state)
if id ~= self.props.id then
return nil
end
repeat
if state == "Disabled" then
self.status = false
break
end
if state == "Enabled" then
self.status = true
break
end
until true
self:UpdateEnabled()
end))
end
function Toolbox:UpdateEnabled()
local _exp = self.status
repeat
if _exp == false then
self.enabledMotor:setGoal(Spring.new(0, params))
return nil
end
if _exp == true then
self.enabledMotor:setGoal(Spring.new(1, params))
return nil
end
until true
end
function Toolbox:willUnmount()
self.janitor:Cleanup()
end
function Toolbox:render()
local _exp = self.props.animation.type
repeat
if _exp == "FADE" then
local pos = self.props.animation.pos
self.posMotor:setGoal({
X = Instant.new(pos.X.Scale),
Y = Instant.new(pos.Y.Scale),
})
self.visibleMotor:setGoal(Instant.new(0))
self.visibleMotor:setGoal(Spring.new(1, params))
break
end
if _exp == "MOVE" then
local pos1 = self.props.animation.pos1
local pos2 = self.props.animation.pos2
self.posMotor:setGoal({
X = Instant.new(pos1.X.Scale),
Y = Instant.new(pos1.Y.Scale),
})
self.posMotor:setGoal({
X = Spring.new(pos2.X.Scale, params),
Y = Spring.new(pos2.Y.Scale, params),
})
break
end
until true
return Roact.createElement("ImageButton", {
Image = nil,
BackgroundColor3 = Color3.fromRGB(0, 0, 0),
BackgroundTransparency = self.visibleBinding:map(handleTransparency(0.95)),
AnchorPoint = Vector2.new(0.5, 0.5),
Position = self.posBinding:map(function(val)
return UDim2.fromScale(val.X, val.Y)
end),
Size = UDim2.new(0.029 * 1.25, 0, 0.052 * 1.25, 0),
[Roact.Event.MouseButton1Click] = function()
if UserInputService.MouseEnabled then
self:Clicked()
end
end,
[Roact.Event.TouchTap] = function()
if UserInputService.TouchEnabled then
self:Clicked()
end
end,
}, {
Roact.createElement("UIAspectRatioConstraint", {
AspectRatio = 1,
}),
Roact.createElement("Frame", {
BackgroundColor3 = Color3.fromRGB(0, 0, 0),
BackgroundTransparency = self.enabledBinding:map(handleTransparency(0.85)),
AnchorPoint = Vector2.new(0.5, 0.5),
Position = UDim2.fromScale(0.5, 0.5),
Size = UDim2.fromScale(1, 1),
}, {
Roact.createElement("UICorner", {
CornerRadius = UDim.new(100, 0),
}),
}),
Roact.createElement("UICorner", {
CornerRadius = UDim.new(100, 0),
}),
Numeral = Roact.createElement("TextLabel", {
BackgroundTransparency = 1,
Font = Enum.Font.Fantasy,
AnchorPoint = Vector2.new(0.5, 0.5),
Position = UDim2.fromScale(0.5, 0.5),
RichText = true,
Size = UDim2.new(0.768, 0, 0.804, 0),
Text = Numerals[self.props.position - 1 + 1],
TextColor3 = Color3.fromRGB(255, 255, 255),
TextScaled = true,
TextSize = 14,
TextTransparency = self.visibleBinding:map(handleTransparency(0.8)),
TextWrapped = true,
}),
Name = Roact.createElement("TextLabel", {
[Roact.Ref] = self.Name,
BackgroundTransparency = 1,
Font = Enum.Font.Fantasy,
Position = UDim2.new(0.107, 0, 0.219, 0),
RichText = true,
Size = UDim2.new(0.768, 0, 0.5, 0),
Text = self.props.tool.Name,
TextColor3 = Color3.fromRGB(255, 255, 255),
TextScaled = true,
TextSize = 14,
TextTransparency = self.visibleBinding:map(handleTransparency(0.3)),
TextWrapped = true,
}),
Roact.createElement("ViewportFrame", {
[Roact.Ref] = self.ViewportFrame,
BackgroundTransparency = 1,
ImageTransparency = self.visibleBinding,
Position = UDim2.new(0.036, 0, 0.036, 0),
Size = UDim2.new(0.036, 0, 0.036, 0),
}),
})
end
function Toolbox:Clicked()
Events.Input({
type = "PARSED",
State = "End",
Input = self.props.tool:GetAttribute("BUTTON_TOGGLE"),
})
end
end
return {
Toolbox = Toolbox,
}