modifique esse script que ao inves de usar o TextButton, use o mesmo imagebutton Toggle…
- User
modifique esse script que ao inves de usar o TextButton, use o mesmo imagebutton Toggle : local Utility = {}
--// services local TweenService = game:GetService('TweenService')
--// variables local AnimationFrame = script.Parent.Parent.MainFrame local ToggleButton = AnimationFrame.Parent.toggle local Player = game.Players.LocalPlayer local scroll = script.Parent.Parent.MainFrame.Content.ScrollingFrame
-- Tween local function tween(obj, assignedProperty, assignedValue, completeTime, easingStyle, easingDirection) TweenService:Create(obj, TweenInfo.new(completeTime, easingStyle or Enum.EasingStyle.Quint, easingDirection or Enum.EasingDirection.Out), { [assignedProperty] = assignedValue }):Play() end Utility.Tween = tween
-- Utility.SetupSectionButton() local SelectedSectionButton = nil function Utility.SetupSectionButton(sectionButton, sectionName) sectionButton.MouseButton1Up:Connect(function() Utility.DisableSectionButtons(sectionButton) SelectedSectionButton = sectionButton tween(sectionButton, 'BackgroundColor3', Color3.fromRGB(255,255,255), 0.5) tween(sectionButton, 'BackgroundTransparency', 0.3, 0.5) tween(sectionButton, 'TextColor3', Color3.fromRGB(0,0,0), 0.5) Utility.Query(sectionName) end) sectionButton.MouseEnter:Connect(function() if SelectedSectionButton ~= sectionButton then tween(sectionButton, 'BackgroundColor3', Color3.fromRGB(30,30,30), 0.5) end end) sectionButton.MouseLeave:Connect(function() if SelectedSectionButton ~= sectionButton then tween(sectionButton, 'BackgroundColor3', Color3.fromRGB(10,10,10), 0.5) end end) end
-- Utility.DisableSectionButtons function Utility.DisableSectionButtons(exception) for i,v in pairs(AnimationFrame.Sections:GetChildren()) do if v:IsA('TextButton') and v ~= exception then tween(v, 'BackgroundColor3', Color3.fromRGB(10,10,10), 0.5) tween(v, 'BackgroundTransparency', 0.7, 0.5) tween(v, 'TextColor3', Color3.fromRGB(255,255,255), 0.5) end end end
-- Utility.SetRunningAnimation() local SelectedButton = nil local PlayingAnimation = nil function Utility.SetRunningAnimation(button) if SelectedButton then tween(SelectedButton, 'BackgroundColor3', Color3.fromRGB(10, 10, 10), 0.5) tween(SelectedButton, 'BackgroundTransparency', 0.7, 0.5) if SelectedButton == button then if PlayingAnimation then PlayingAnimation:Stop() end SelectedButton = nil PlayingAnimation = nil return end end SelectedButton = button tween(SelectedButton, 'BackgroundColor3', Color3.fromRGB(255,255,255), 0.5) tween(SelectedButton, 'BackgroundTransparency', 0.7, 0.5) if PlayingAnimation then -- stop the running animation PlayingAnimation:Stop() end -- load new animation PlayingAnimation = Player.Character.Humanoid.Animator:LoadAnimation(button.WorldModel.Animation) -- Set the animation priority to "Action" PlayingAnimation.Priority = Enum.AnimationPriority.Action PlayingAnimation:Play() end
-- Utility.SetupNewButton() function Utility.SetupNewButton(newButton) newButton.MouseEnter:Connect(function() if SelectedButton ~= newButton then tween(newButton, 'BackgroundColor3', Color3.fromRGB(100, 100, 100), 0.5) end end) newButton.MouseLeave:Connect(function() if SelectedButton ~= newButton then tween(newButton, 'BackgroundColor3', Color3.fromRGB(0,0,0), 0.5) end end) end
-- Utility.Query() function Utility.Query(text) for i, v in pairs(AnimationFrame.Content.ScrollingFrame:GetChildren()) do if v:IsA('ViewportFrame') then v.Visible = (not text and true) or string.find(v:GetAttribute('Section'):lower(), text:lower()) end end end
-- Utility.EnableToggleButton function Utility.EnableToggleButton() scroll.Visible = true end
function Utility.DisableToggleButton() scroll.Visible = false end
return Utility
- Assistant
Sure! I've modified your script to use
ImageButtoninstead ofTextButton, as per your request. The main changes involve replacing references toTextButtonwithImageButtonand adjusting properties that are specific toTextButton. Here's the updated script:local Utility = {} --// Services local TweenService = game:GetService('TweenService') --// Variables local AnimationFrame = script.Parent.Parent.MainFrame local ToggleButton = AnimationFrame.Parent.toggle -- Assuming 'toggle' is an ImageButton local Player = game.Players.LocalPlayer local scroll = script.Parent.Parent.MainFrame.Content.ScrollingFrame -- Tween Function local function tween(obj, assignedProperty, assignedValue, completeTime, easingStyle, easingDirection) TweenService:Create(obj, TweenInfo.new(completeTime, easingStyle or Enum.EasingStyle.Quint, easingDirection or Enum.EasingDirection.Out), { [assignedProperty] = assignedValue }):Play() end Utility.Tween = tween -- Utility.SetupSectionButton() local SelectedSectionButton = nil function Utility.SetupSectionButton(sectionButton, sectionName) sectionButton.MouseButton1Up:Connect(function() Utility.DisableSectionButtons(sectionButton) SelectedSectionButton = sectionButton tween(sectionButton, 'BackgroundColor3', Color3.fromRGB(255, 255, 255), 0.5) tween(sectionButton, 'BackgroundTransparency', 0.3, 0.5) -- Since ImageButton doesn't have 'TextColor3', we can change 'ImageColor3' or adjust a child TextLabel if needed tween(sectionButton, 'ImageColor3', Color3.fromRGB(0, 0, 0), 0.5) Utility.Query(sectionName) end) sectionButton.MouseEnter:Connect(function() if SelectedSectionButton ~= sectionButton then tween(sectionButton, 'BackgroundColor3', Color3.fromRGB(30, 30, 30), 0.5) end end) sectionButton.MouseLeave:Connect(function() if SelectedSectionButton ~= sectionButton then tween(sectionButton, 'BackgroundColor3', Color3.fromRGB(10, 10, 10), 0.5) end end) end -- Utility.DisableSectionButtons function Utility.DisableSectionButtons(exception) for i, v in pairs(AnimationFrame.Sections:GetChildren()) do if v:IsA('ImageButton') and v ~= exception then tween(v, 'BackgroundColor3', Color3.fromRGB(10, 10, 10), 0.5) tween(v, 'BackgroundTransparency', 0.7, 0.5) tween(v, 'ImageColor3', Color3.fromRGB(255, 255, 255), 0.5) end end end -- Utility.SetRunningAnimation() local SelectedButton = nil local PlayingAnimation = nil function Utility.SetRunningAnimation(button) if SelectedButton then tween(SelectedButton, 'BackgroundColor3', Color3.fromRGB(10, 10, 10), 0.5) tween(SelectedButton, 'BackgroundTransparency', 0.7, 0.5) if SelectedButton == button then if PlayingAnimation then PlayingAnimation:Stop() end SelectedButton = nil PlayingAnimation = nil return end end SelectedButton = button tween(SelectedButton, 'BackgroundColor3', Color3.fromRGB(255, 255, 255), 0.5) tween(SelectedButton, 'BackgroundTransparency', 0.7, 0.5) if PlayingAnimation then PlayingAnimation:Stop() end -- Load new animation PlayingAnimation = Player.Character.Humanoid.Animator:LoadAnimation(button.WorldModel.Animation) -- Set the animation priority to "Action" PlayingAnimation.Priority = Enum.AnimationPriority.Action PlayingAnimation:Play() end -- Utility.SetupNewButton() function Utility.SetupNewButton(newButton) newButton.MouseEnter:Connect(function() if SelectedButton ~= newButton then tween(newButton, 'BackgroundColor3', Color3.fromRGB(100, 100, 100), 0.5) end end) newButton.MouseLeave:Connect(function() if SelectedButton ~= newButton then tween(newButton, 'BackgroundColor3', Color3.fromRGB(0, 0, 0), 0.5) end end) end -- Utility.Query() function Utility.Query(text) for i, v in pairs(AnimationFrame.Content.ScrollingFrame:GetChildren()) do if v:IsA('ViewportFrame') then v.Visible = (not text and true) or string.find(v:GetAttribute('Section'):lower(), text:lower()) end end end -- Utility.EnableToggleButton function Utility.EnableToggleButton() scroll.Visible = true end function Utility.DisableToggleButton() scroll.Visible = false end return UtilityExplanation of Changes:
-
Replaced
TextButtonwithImageButton:- Updated all instances where
TextButtonwas referenced, changing it toImageButton, such as inv:IsA('ImageButton').
- Updated all instances where
-
Adjusted Properties:
- Since
ImageButtondoes not have aTextColor3property, I replaced it withImageColor3, which changes the color of the image. - Removed any references to properties that are specific to
TextButtonand not available inImageButton. - For changing text properties, if your
ImageButtonhas a childTextLabelorTextButton, you can adjust its properties by accessing it throughsectionButton.TextLabelorsectionButton:FindFirstChild("TextLabel").
- Since
-
Event Connections:
- Ensured that all event connections (
MouseButton1Up,MouseEnter,MouseLeave) are compatible withImageButton.
- Ensured that all event connections (
Additional Notes:
-
Adjusting Text Within ImageButton:
- If your
ImageButtoncontains text as a child element (e.g., aTextLabel), you might need to adjust the script to change the text color or other properties of the child element. For example:local textLabel = sectionButton:FindFirstChildOfClass("TextLabel") if textLabel then tween(textLabel, 'TextColor3', Color3.fromRGB(0, 0, 0), 0.5) end - Insert this code where you need to adjust the text properties.
- If your
-
ImageColor3 Effect:
- The
ImageColor3property tints the image of theImageButton. This works best if the image is designed to be color-tintable (e.g., white icons that can be tinted with colors). If your images are full-color, changingImageColor3might not produce the desired effect.
- The
-
Testing:
- After implementing the script, test the buttons to ensure that they behave as expected, and adjust the properties or event connections as needed.
Let me know if you need further assistance or any other modifications!
-