Hi, my dev partner and I are currently stuck on an issue that is holding us back from releasing the game. We can’t figure out a way to make the tool the player creates show up on the server. I have been thinking of ways to use a remote event but I realized that I can only fire the event through a script. The issue we have is that we are forced to use a local script to interact with an inventory system that is only for individual clients. Is there any way we can use a local script to fire a remote event?
(I was messing around and was wondering if it’s possible to fire a remote event through a regular script by somehow connecting the local script to the regular script after a specific action is done.
Sorry if this question is vague or challenging to respond to. Not really sure how else to ask this question.
Local scripts are the only way to fire remote events - that’s quite frankly what remote events were designed for in the first place. The server is responsible for listening for server events, not firing them.
Uhh, What?, Your tool seems to be located on the client, this is your problem. If you want to fix this you need to make the core of the tool on the server.
the server needs to give the player a tool, if you use a LocalScript (aka the client) to give a player a tool then it wont replicate and the server wont see it.
if your REALLY need to give tools via a localscript then I would look into RemoteEvents
This will allow a LocalScript to ‘request’ the server to give the player a tool.
On the wiki the example of a localscript using a FireServer function is shown. I’m still new to coding and I was wondering what types of arguments I can put inside the brackets for FireServer. Are they Tuple?
-- LocalScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local createPartEvent = ReplicatedStorage:WaitForChild("CreatePartEvent")
createPartEvent:FireServer(BrickColor.Green(), Vector3.new(10, 20, 0))
You can put virtually anything within the brackets. The server takes whatever the client is sending in the fire event, and uses it on the server side.
For example:
-- Client
RemoteEvent:FireServer(true, "Hello World")
-- Server
RemoteEvent.OnServerEvent:Connect(function(Player, A, B)
print(Player.Name, A, B)
end)
This would in turn print the Player’s name, the boolean true, and the string “Hello World”. A is representative of the boolean, whilst B is representative of the string.
Okay this helped a lot. I realized I could just run a function inside the brackets and then I duplicated the tool on the server side. Thanks for your help!