Hello! Recently I’ve been making a HandTo Command, and I’ve come up with an issue and question on :
How can I send a ScreenGui to the player, that says “Accept/Decline” and then if they accept the request of someone asking to “give them the tool” then it will put the tool in their backpack.
Now the main importance of this that I’m misunderstanding is how to send the TargetedPlayer, and the TargetedTool to the client side from the server side.
What I have started :
- Serverscript
--[[
@since 08/07/2022
@author TwinPlayzDev
youtube.com/c/TwinPlayz_YT for more information on this video.
This is an updated version of v1. Which didn't include the confirmation GUI.
--]]
--[[ SERVICES ]]--
local Players = game:GetService("Players") -- GETTING ALL PLAYERS
--[[ VARIABLES ]]--
local Prefix = script:GetAttribute("Prefix") -- COMMAND PREFIX
local GroupID = 8428801 -- PUT YOUR GROUP ID HERE
local MinRank = 5 -- PUT MINIMUM RANK TO USE COMMAND HERE
local GUI = script:WaitForChild("AcceptGUI") -- GUI WE USE
--[[ FUNCTIONS ]]--
game.Players.PlayerAdded:Connect(function(player) -- When they join
player.CharacterAppearanceLoaded:Connect(function(char) -- When their character loads
player.Chatted:Connect(function(message) -- When they chat
if player:IsInGroup(GroupID) then -- We check if their in group
local lower = message:lower() -- Getting the message lower
local args = lower:split(" ") -- Splitting the message
--[ UNIFORM COMMAND ]--
if player:GetRankInGroup(GroupID) >= MinRank then -- Check if their ranked high enough
if args[1] == Prefix.."handto" then -- Check if its command
local function GetPlayer(Input) -- Local function get player
for _, Player in ipairs(Players:GetPlayers()) do -- Checks all players
if (string.lower(Input) == string.sub(string.lower(Player.Name), 1, #Input)) then
return Player -- Returns the player we found
end
end
end
if not args[2] then return end -- If they didn't type a players name
local targetPlayer = GetPlayer(args[2]) -- Getting the player
if targetPlayer and targetPlayer:IsA("Player") then -- If we found the player
print(targetPlayer.Name) -- Print their name
local TargetTool = player.Character:FindFirstChildOfClass("Tool") -- Find Tool to give
if TargetTool then
print("giving tool")
local NewGUI = GUI:Clone() -- Clones GUI
NewGUI.Frame.Info = "Player: ".. targetPlayer.Name .. ", would like to send you: "..TargetTool.Name
NewGUI.Parent = targetPlayer:WaitForChild("PlayerGui") -- Gives GUI
-- WHERE YOU WOULD SEND THE TOOL
end
end
end
else
print("Not Ranked High Enough") -- Letting us know their not ranked high enough
end
else
print("Not In Group") -- Letting us know their not in group
end
end)
end)
end)
- Local Script
--[[
@since 08/07/2022
@author TwinPlayzDev
youtube.com/c/TwinPlayz_YT for more information on this video.
This is an updated version of v1. Which didn't include the confirmation GUI.
--]]
--[[ VARIABLES ]]--
local AcceptButton = script.Parent:WaitForChild("ACCEPT")
local DeclineButton = script.Parent:WaitForChild("DECLINE")
local GUI = script.Parent.Parent
--[[ FUNCTIONS ]]--
AcceptButton.Activated:Connect(function()
GUI:Destroy()
end)
DeclineButton.Activated:Connect(function()
GUI:Destroy()
end)
It’s already made and ready, just curious how I could send the tool,to the client side, and if they accept the request, then they will receive that tool.
Thank you