I want to grab a text input from a GUI but I can't figure out how. This is my current script, it checks if a player has executed anything in 120 and they haven't then it sends a message to a discord webhook. Can someone tell me what I'm doing wrong?
local webhook = "I removed the webhook"
local Players = game:GetService("Players")
local http = game:GetService("HttpService")
local inputBox = script.Parent.InputBox
local PlayerInfo = {}
function checkPlayerName(plr)
if PlayerInfo[tostring(plr)] then
return true
end
return false
end
Players.PlayerAdded:Connect(function(plr)
if not checkPlayerName(plr.UserId) then
PlayerInfo[tostring(plr.UserId)] = 0
end
end)
Players.PlayerRemoving:Connect(function(plr)
if checkPlayerName(plr.UserId) then
PlayerInfo[tostring(plr.UserId)] = nil
end
end)
Players.PlayerAdded:Connect(function(plr)
script.Parent.SendReport.MouseButton1Click:Connect(function(text)
text = inputBox.Text
local currentTick = tick()
if currentTick - PlayerInfo[tostring(plr.UserId)] >= 120 then
PlayerInfo[tostring(plr.UserId)] = currentTick
local data = {
['embeds'] = {{
['title'] = "New report from: " .. plr.Name,
['description'] = "Report: " .. text
}}
}
http:PostAsync(webhook, http:JSONEncode(data))
end
end)
end)

1 comment
You don't need the player added event if this script is inside of a text button. You just need to activate the script when the player clicks it.