I have a script here however whenever I activated a gui locally that clones a tool, the server can’t seem to detect it whenever I’m passing it to another player via local gui.
The process Goes:
Player GUI TextBox > RemoteEvent > ServerScript (Detecting Tools from the player that Activated the TextBox) and Clones it to their Backpack
However the script works up until detecting the Tools from my Backpack, but it won’t get passed through to the target player.
These are the Scripts:
--// Local Script from StarterGUI
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
Cont_Fin.Activated:Connect(function()
local NameBoxText = NameBox.Text
if NameBoxText ~= "" then
local playerName = getPlayerFromPartialName(NameBoxText)
if playerName then
GPI_EVNT:FireServer(playerName)
NameBox.Text = ""
NameBox.PlaceholderText = "Gave!"
wait(1)
NameBox.PlaceholderText = "Player Name Here"
Cont_Fin.Visible = false
Finish_Area.Text_Label.Text = "Your order has been Delivered!"
Detail_EVNT:FireServer("FinishedTransaction")
wait(3)
Finish_Area.Visible = false
Claiming_Area.Visible = true
Selection_Area.Visible = false
Cont_Fin.Visible = true
else
NameBox.Text = ""
NameBox.PlaceholderText = "Player Not Found!"
wait(1)
NameBox.PlaceholderText = "Player Name Here"
end
end
end)
and here’s the script on the server:
--// Server Script
GPI_EVNT.OnServerEvent:Connect(function(Player, PlayerName)
for _, Tool in pairs(Player.Backpack:GetChildren()) do
Tool.Parent = game.Players[PlayerName].Backpack
end
end)
It is better to do an encryption process for passing RemoteEvent likes tool → special string value that identified the tool for client-server info sharing I rarely ever send information of instance added from client to server even if it works as it is unreliable and very HEAVY data as it is an instance. If you needs a way for server to find client added tool I recommend making a custom server sided script that keeps track of ‘encryption key’ tool and pass information through it.
It might sounds difficult but I thinks there are module that are meant for encrypted remote method also I suggest using RemoteFunction over event if there are only 1 script using the event.
Sorry, but I am trying my best to understand the problem. It seems like you are creating a system where players input a target player’s name in a TextBox instance, and then parents all the available tools in the player’s backpack to the target player’s backpack?
That is not how you are supposed to use RemoteFunctions. You use RemoteFunctions if you are invoking the server/client and yields the current code until the other side receives something. RemoteEvents are used for one-way-communications.
oh I do have a separate local script under the separate button that gives the tool in which clones the tool to the Player’s backpack.
And therefore, this script I gave here is different.
Basically, I have a separate Tool Giver Script that gives the tool locally to the player, and then the script I gave here tries to get the tools of the character and therefore gives it to the target player.
Perhaps I use RemoteFunction as the purpose of good debugging and it also quick. Sending information back also gives more option.
Edit: sorry but ‘quick’ wasn’t the word I meant, what I meant was information is easier to process if it get send back to client instead of connecting to 2 events.
yes so basically player 1 would input the target’s username in a TextBox and then presses a button that activates the local script to fire to the server that the server will then find all of the player that activated the button their tools and gets given to the targeted player
In this case RemoteFunctions aren’t necessary, unless the OP requires the server to return back something to the client after the client invoked the server. Also, RemoteFunctions ARE NOT FASTER THAN RemoteEvents.
Can you please show us the AddItem local script code? That is the major problem here as the codes you have provided in the post can’t really help us to find the root cause.
local Items = game:GetService("ReplicatedStorage"):WaitForChild("StoreEvents"):WaitForChild("Cafe"):WaitForChild("Cafe_Items"):WaitForChild("Expresso&Coffee")
local EVNT = Items.Parent.Details
local Button = script.Parent
local Item_1 = Items:WaitForChild("BrewedBlondeRoast")
local Item_Lists= script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.CustomerScreen.ReceiptFrame.MiddleFrame.ReceiptArea.Items
local Backpack = game:GetService("Players").LocalPlayer.Backpack
Button.Activated:Connect(function()
EVNT:FireServer("EX_BBR")
Item_1:Clone().Parent = Backpack
end)
Alright, before I can tell you the answer, I need to understand, why are you cloning the tool to the player’s backpack on the client side? Can’t you just do the same thing on the server side? Any changes occur on the client can’t be replicated across the server-client boundaries.
This whole thing can be resolved by moving the cloning tool logic from the client to the server.
wait so your telling me, if I change the script to server this could have worked??? well my only thought rn is I thought server scripts won’t work under StarterGui to clone the tool to the Player’s backpack
Remember, anything that a local script tries to change on the client, CANNOT BE VIEWED OBSERVED BY OTHER PLAYERS. This works because of workspace.FilteringEnabled which is helpful to combat exploits.
Use the RemoteEvent to tell the server to clone the tools to the player’s backpack. Do the cloning tools logic on the server side.
You can read more about server-client boundaries via
Your tools should be in ServerStorage and cloned to the players from there via server script. You can use a remote from a client script. Stuff like this will get hacked to death.