Hey everyone!
I’ve just made a hand to system for my game and am wondering how I could implement some code in the following script to make it post a log to Discord using a webhook every time an item is handed to a player using the GUI. It would be something like “(PLAYER USERNAME) has handed (ITEM NAME) to (PLAYER USERNAME)!” The script is provided below, let me know if you can provide assistance with how to script this. Also, I know this isn’t the place to ask for scripts but I’ve looked everywhere and haven’t found anything of assistance. Thank you in advance for your assistance with this!
Local Script:
local Player = game.Players.LocalPlayer
local HandtoGui = script.Parent.Parent.Parent.Parent.FirstFrame
local NameBox = HandtoGui.SecondFrame.HandToGui.NameFrame.NameBox
local GiveButton = HandtoGui.SecondFrame.HandToGui.GiveFrame.GiveButton
local groupId = 7331168 --Group Id Here
local minimumRankToUseGui = 2 --Minimum Rank To Use Handto Gui Here
if Player:GetRankInGroup(groupId) < minimumRankToUseGui then
HandtoGui:Destroy()
end
local function getPlayerFromPartialName(PartialName)
local foundName = nil
local Players = game.Players:GetPlayers()
for i = 1, #Players do
local PossiblePlayer = Players[i]
if string.find(string.lower(PossiblePlayer.Name), string.lower(PartialName)) then
foundName = PossiblePlayer.Name
end
end
if not foundName then
return nil
else
return foundName
end
end
GiveButton.MouseButton1Click:Connect(function()
if not Player.Character:FindFirstChildWhichIsA("Tool") then
NameBox.Text = ""
NameBox.PlaceholderText = "Equip a Tool First!"
wait(1)
NameBox.PlaceholderText = "USERNAME"
end
local NameBoxText = NameBox.Text
if NameBoxText ~= "" then
local playerName = getPlayerFromPartialName(NameBoxText)
if playerName then
print("Found player")
game.ReplicatedStorage.GivePlayerItem:FireServer(playerName)
NameBox.Text = ""
NameBox.PlaceholderText = "Gave!"
wait(1)
NameBox.PlaceholderText = "USERNAME"
else
NameBox.Text = ""
NameBox.PlaceholderText = "Player Not Found!"
wait(1)
NameBox.PlaceholderText = "USERNAME"
end
end
end)
Server Script:
game.ReplicatedStorage.GivePlayerItem.OnServerEvent:Connect(function(Player, PlayerName)
if Player.Name ~= PlayerName then
local ToolToGive = Player.Character:FindFirstChildWhichIsA("Tool")
ToolToGive.Parent = game.Players[PlayerName].Backpack
Player.leaderstats.Points.Value = Player.leaderstats.Points.Value + 1
end
end)