How would I convert this code to work when a “TextButton” is clicked, I have started using SurfaceGuis, so this is something important for me to achieve.
local ToolNames = {"Taser"}
local Storage = game:GetService("ServerStorage")
local Part = script.Parent
local ClickDetector = Part:WaitForChild("ClickDetector")
ClickDetector.MouseClick:connect(function(Player)
if Player and Player.Character then
local Backpack = Player:WaitForChild("Backpack")
for i = 1, #ToolNames do
local Tool = Storage:FindFirstChild(ToolNames[i])
if Tool then
wait(10)Tool:clone().Parent = Backpack
end
end
end
end)