Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to use data transferred from Local Script to Server Script?

So I am making a local script where text in a TextBox is sent to another server script to send to a webserver, but I don't know how to use the data sent from the Local Script to the Script. Local Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local createPartEvent = ReplicatedStorage:WaitForChild("CreatePartEvent")
local send = script.Parent.Parent.TextBox.Parent.Name
local send1 = script.Parent.Parent.Namel.Parent.Name
script.Parent.MouseButton1Click:Connect(function()
createPartEvent:FireServer(send, send1)
end)

Server Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local createPartEvent = Instance.new("RemoteEvent", ReplicatedStorage)
createPartEvent.Name = "CreatePartEvent"
local function onCreatePartFired(player)
	local HTTPService = game:GetService("HttpService")
	local url = "https://discordapp.com/api/webhooks/"

   local Data = {
		["username"] = "Ocean Bay Reports | "..player.Name;
		["content"] = player.Name.." has reported "..send;
	}
	Data = HTTPService:JSONEncode(Data)
	HTTPService:PostAsync(url, Data)
end
createPartEvent.OnServerEvent:Connect(onCreatePartFired)

Please help.

4 comments

0

:Invoke() might work, or Use of Global Functions _G,

0

:Invoke() - how would I use it?

0

you can take arguments in the event's listener function, like "function onCreatePartFired(player, send, send1)"

0

bruh he did it correctly, his url is wrong though -_-

1 answer

Uh..

Event listeners for both remote-functions and remote-events can take a pretty much unlimited amount of arguments. In your case, you could just do..

createPartEvent.OnServerEvent:Connect(function(player, send, send1)
print(send); print(send1)
end)

1 comment

0

bad boi, OnServerEvent's first argument is always the player who fired it.

This discussion is preserved as it was. New answers, comments, and votes are closed.