How Do I Make This Script Only Run If A TextButton is pressed?

local debounce = false
local button = game:GetService(“StarterGui”).PunchUpsAnim

script.Parent.Touched:Connect(function(hit)
if hit.Name == “RightHand” then
if hit.Parent:FindFirstChild(“Humanoid”) then
if debounce == false then
local player = game.Players:FindFirstChild(hit.Parent.Name)
player.leaderstats.Speed.Value = player.leaderstats.Speed.Value + 10
debounce = true
wait(3)
debounce = false
end
end
end
end)

Will it work once or for ever?

Use

script.Parent.MouseButton1Click:Connect(function()
  if hit.Name == “RightHand” then
    if hit.Parent:FindFirstChild(“Humanoid”) then
       if debounce == false then
          local player = game.Players:FindFirstChild(hit.Parent.Name)
          player.leaderstats.Speed.Value = player.leaderstats.Speed.Value + 10
          debounce = true
          wait(3)
          debounce = false
       end
      end
    end
end)

the parent of my script is the part

local debounce = false
local button = game:GetService(“StarterGui”).PunchUpsAnim
local x = false

script.Parent.Touched:Connect(function(hit)
if x == true then
if hit.Name == “RightHand” then
if hit.Parent:FindFirstChild(“Humanoid”) then
if debounce == false then
local player = game.Players:FindFirstChild(hit.Parent.Name)
player.leaderstats.Speed.Value = player.leaderstats.Speed.Value + 10
debounce = true
wait(3)
debounce = false
end
end
end
end
end)

game.StarterGui.TextButton.MouseButton1Click:Connect(function()
x = true
end)

Something like this, however I cannot reference the script for you because I don’t know the positions and names of everything

local button = -- button
button.MouseButton1Click:Connect(function()
script.Parent.Touched:Connect(function()
-- the script
end)
end)

Try this out, i use this every times
This one is only for model, If your button is a Gui/TextButton then you might need to use a different script.

local debounce = false
local button = game:GetService(“StarterGui”).PunchUpsAnim

script.Parent.Touched:Connect(function(hit)
       local RightArm = hit.Parent:FindFirstChild(Right Arm) --The body you want it to run the script when touched by
       if RightArm and debounce == false then
          local humanoid = hit.Parent:FindFirstChild(Humanoid)
          if humanoid then
          local player = game.Players:FindFirstChild(hit.Parent.Name)
          player.leaderstats.Speed.Value += 10
          debounce = true
          wait(3)
          debounce = false
               end
       end
end)