Hello, there. I’m trying to make this button that’s repeatable but it doesn’t seem to be working. There’s no error popping up in error. I’m just trying to make this to work, i even made a post, no one responded to that. probably no one will respond to this one also
-- ButtonActions
-- Button Tween
local debounce = 0
local TweenService = game:GetService("TweenService")
local ButtonStages = {
DefaultColor = Color3.fromRGB(138, 255, 146),
PressedColor = Color3.fromRGB(0, 0, 0)
}
local ButtonTweenInfo = TweenInfo.new(
.5,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
-- Variables
local ButtonActions = {}
local ButtonsFolder = workspace:WaitForChild("Game"):WaitForChild("Buttons")
-- Function
local function GetButtonByID(id)
for _, child in ipairs(ButtonsFolder:GetChildren()) do
child:WaitForChild("ID")
if child.ID.Value == id then
return child
end
end
end
function ButtonActions:Run(id)
local button = GetButtonByID(id)
if button then
button:WaitForChild("Button")
local ButtonTween = TweenService:Create(button.Button, ButtonTweenInfo, {Position = button.Button.Position + Vector3.new(0, -.3, 0), Color = ButtonStages.PressedColor})
ButtonTween:Play()
require(script:WaitForChild(tostring(id))):Execute()
wait(2)
debounce = 1
end
end
-- Return
return ButtonActions
-- ThIs will tell what the obstacle will do
-- Services
local debounce = 0
local TweenService = game:GetService("TweenService")
-- Variables
local Obstacle = game.Workspace.Game.Obstacles.ObstaclePartA
local ObstacleTweenInfo = TweenInfo.new(
0,
Enum.EasingStyle.Quint,
Enum.EasingDirection.Out,
0,
false,
0
)
local Functions = {}
-- Execute
function Functions:Execute()
print("Button with the ID" .. script.Parent.Name .."was pressed")
local ObstacleTween = TweenService:Create(Obstacle, ObstacleTweenInfo, {Transparency = 1, Position = Vector3.new(0, -25, 0)})
ObstacleTween:Play()
wait(5)
debounce = 1
end
-- Return
return Functions
if debounce == 0 then
debounce = 1
end
local TweenService = game:GetService("TweenService")
-- Variables
local Obstacle = game.Workspace.Game.Obstacles.ObstaclePartA
local ObstacleTweenInfo = TweenInfo.new(
30,
Enum.EasingStyle.Quint,
Enum.EasingDirection.Out,
0,
false,
0
)
local Functions = {}
-- Execute
function Functions:Execute()
print("Button with the ID" .. script.Parent.Name .."was pressed")
local ObstacleTween = TweenService:Create(Obstacle, ObstacleTweenInfo, {Transparency = 0, Position = Vector3.new(-86.45, -4.5, 75)})
ObstacleTween:Play()
wait(2)
debounce = 0
end
-- Return
return Functions
Button Actions:
-- Button Tween
local TweenService = game:GetService("TweenService")
local ButtonStages = {
DefaultColor = Color3.fromRGB(138, 255, 146),
PressedColor = Color3.fromRGB(0, 0, 0)
}
local ButtonTweenInfo = TweenInfo.new(
.5,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
-- Variables
local ButtonActions = {}
local ButtonsFolder = workspace:WaitForChild("Game"):WaitForChild("Buttons")
-- Function
local function GetButtonByID(id)
for _, child in ipairs(ButtonsFolder:GetChildren()) do
child:WaitForChild("ID")
if child.ID.Value == id then
return child
end
end
end
function ButtonActions:Run(id)
local button = GetButtonByID(id)
if button then
button:WaitForChild("Button")
local ButtonTween = TweenService:Create(button.Button, ButtonTweenInfo, {Position = button.Button.Position + Vector3.new(0, -.3, 0), Color = ButtonStages.PressedColor})
ButtonTween:Play()
require(script:WaitForChild(tostring(id))):Execute()
end
end
-- Return
return ButtonActions
Button Handler: (i forgot to add this earlier)
local ButtonActions = require(script.Parent.ButtonActions)
local Buttons = {}
local ButtonHandler = {}
local buttonsFolder: Folder = workspace:WaitForChild("Game"):WaitForChild("Buttons")
local function FindButton(id)
for _, child in ipairs(buttonsFolder:GetChildren()) do
if child.Name == "ButtonModel" then
child:WaitForChild("ID")
if child.ID.Value == id then
return child
end
end
end
end
function ButtonHandler:Init()
for _, child in ipairs(buttonsFolder:GetChildren()) do
if child.Name == "ButtonModel" then
child:WaitForChild("ID")
Buttons[child.ID.Value] = false
end
end
end
local OnChildAdded = function (child)
child:WaitForChild("Button")
child:WaitForChild("ID")
child.Button.Touched:Connect(function ()
if Buttons[child.ID.Value] == true then return end
Buttons[child.ID.Value] = true
ButtonActions:Run(child.ID.Value)
end)
end
buttonsFolder.ChildAdded:Connect(OnChildAdded)
for _, child in ipairs(buttonsFolder:GetChildren()) do
OnChildAdded(child)
end
return ButtonHandler