generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Passing multiple arguments remote event

Previous Thread :: Next Thread 
gunter5 is not online. gunter5
Joined: 15 Mar 2011
Total Posts: 737
20 Nov 2016 08:42 PM
so lets say i have this on a FE game. This would work as it should.


------[Local Script]-------
local RStorage = game:GetService("ReplicatedStorage")
local remote = RStorage:WaitForChild("Remote")
local player = game:GetService("Players").LocalPlayer

player.Chatted:connect(function(msg)
remote:FireServer(msg)
end)
-----------[end]-------------



------[Server Script]------
local SStorage = game:GetService("ServerStorage")
local RStorage = game:GetService("ReplicatedStorage")
local remote = RStorage:WaitForChild("Remote")

remote.OnServerEvent:connect(function(player, msg)
if msg:sub(1,msg:len()):lower() == "test" then
---- code
end
end)

-----------[end]-------------


But what im wanting to do is this.

------[Local Script]-------
local RStorage = game:GetService("ReplicatedStorage")
local remote = RStorage:WaitForChild("Remote")
local player = game:GetService("Players").LocalPlayer

character = game.Workspace:WaitForChild(player.Name)
human = character:WaitForChild("Humanoid")

player.Chatted:connect(function(msg)
remote:FireServer(msg, character, human)
end)
-----------[end]-------------



------[Server Script]------
local SStorage = game:GetService("ServerStorage")
local RStorage = game:GetService("ReplicatedStorage")
local remote = RStorage:WaitForChild("Remote")

remote.OnServerEvent:connect(function(player, msg, character, human)
if msg:sub(1,msg:len()):lower() == "test" then
---- code
end
end)

-----------[end]-------------

im wanting to be able to pass multiple arguments. Any way i can do this?

#code print (string.char(73, 32, 107, 105, 108, 108, 101, 100, 32, 109, 117, 102, 97, 115, 97))
Report Abuse
deranged_Jojo is not online. deranged_Jojo
Joined: 27 Sep 2012
Total Posts: 149
20 Nov 2016 08:43 PM
put all the arguments in a table and send the table, then use table[1] to get the first argument, table[2] to get the second, etc


Report Abuse
PerilousDanger is not online. PerilousDanger
Joined: 21 Aug 2012
Total Posts: 3773
20 Nov 2016 08:46 PM
It should work the way you put it;

remote:FireServer(arg1,arg2,arg3)

remote.OnServerEvent:connect(function(plr,arg1,arg2,arg3)
-- code
end)


But if you're just sending the server an onChatted event

You can do something like this in a server script:


game.Player.PlayerAdded:connect(function(plr)
plr.Chatted:connect(function(msg)
if msg:sub(1,msg:len()):lower() == "test" then
-- print(plr.Character.Name)
-- print(plr.Character.Humanoid.Name)
end
end)
end)
Report Abuse
gunter5 is not online. gunter5
Joined: 15 Mar 2011
Total Posts: 737
20 Nov 2016 08:59 PM

what if i wanted to send a variable. like

character = game.Workspace:WaitForChild(player.Name)
human = character:WaitForChild("Humanoid")

then send the whole variable via a table. can anyone give an ex?

#code print (string.char(73, 32, 107, 105, 108, 108, 101, 100, 32, 109, 117, 102, 97, 115, 97))
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image