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 a table through a RemoteEvent

Previous Thread :: Next Thread 
badgraphix is not online. badgraphix
Joined: 26 Nov 2007
Total Posts: 22800
13 Jan 2016 04:59 PM
Hi, I seem to be having trouble here.

I'm using a remote event, passing information from the local script into the server script.

workspace.Master_Movement.UpdateInputs:FireServer(creature, holding)

The trouble I'm having here is with "holding," which passes in the following information:

holding = {
[Enum.KeyCode.W.Name] = false,
[Enum.KeyCode.A.Name] = false,
[Enum.KeyCode.S.Name] = false,
[Enum.KeyCode.D.Name] = false
}



In the server script though, it doesn't recognize it properly.
For example, I will try the following bite of code:

if holding[Enum.KeyCode.W.Name] == false then
print("it's alive")
end

If this code was in the local script, it would work fine, but in this server script, it gives me "W is not the a valid member of Part"
(W is Enum.KeyCode.W.Name)


I'm guessing you can see what the problem is--the remote event doesn't seem to pass in the whole table. Does anyone know how to fix this?
Report Abuse
badgraphix is not online. badgraphix
Joined: 26 Nov 2007
Total Posts: 22800
14 Jan 2016 12:08 AM
bump
Report Abuse
Hexworx is not online. Hexworx
Joined: 19 Nov 2015
Total Posts: 217
14 Jan 2016 12:55 AM
I have no idea what your 'creature' variable is. However, I do have a funny feeling your error is to do with the parameter setup on your OnServerEvent event.
Report Abuse
ThaneTheCreator is not online. ThaneTheCreator
Joined: 08 Apr 2009
Total Posts: 2182
14 Jan 2016 01:03 AM
RemoteEvents can't pass tables through properly, it's stated in the limitations of using RemoteEvents and RemoteFunctions.
Report Abuse
ScytheAffinity is not online. ScytheAffinity
Joined: 03 Jul 2012
Total Posts: 115
14 Jan 2016 01:04 AM
trash do u even know how to serialize table?
Report Abuse
ThaneTheCreator is not online. ThaneTheCreator
Joined: 08 Apr 2009
Total Posts: 2182
14 Jan 2016 01:08 AM
/\ stfu, I don't like you.
Report Abuse
badgraphix is not online. badgraphix
Joined: 26 Nov 2007
Total Posts: 22800
14 Jan 2016 01:48 AM
Dang, so will I have to pass each of the elements of the table in individually or is there a workaround?


It's not really important to this particular topic but creature is an object value.
Report Abuse
ThaneTheCreator is not online. ThaneTheCreator
Joined: 08 Apr 2009
Total Posts: 2182
14 Jan 2016 01:51 AM
Yea, you might have to pass them each individually. I believe You can pass a table if all values are the same type, like Bool, Int, or String.

I don't think you can pass Instances through RemoteEvents.
Report Abuse
badgraphix is not online. badgraphix
Joined: 26 Nov 2007
Total Posts: 22800
14 Jan 2016 01:16 PM
It appears I'm still having trouble. I've changed to using a RemoteFunction of the same name.



--In the local script:

workspace.Master_Movement.UpdateInputs:InvokeServer(creature, true)


--In the server script:

script.UpdateInputs.OnServerInvoke = function(creature, holding)
if holding == true then
print("it's alive")
end
end



Now if you look I should get the printed message "it's alive" since I'm passing in true under the value "holding". However, instead I get nothing. Not even an error message. Can someone tell me what I'm doing wrong here? The only one of these things I've ever really used is bindable functions.
Report Abuse
Hexworx is not online. Hexworx
Joined: 19 Nov 2015
Total Posts: 217
14 Jan 2016 01:19 PM
I had tried this last night, it worked fine for me.

-- local script

local event = game.Workspace:WaitForChild("Event")

local dictionary = {
[Enum.KeyCode.W.Name] == false,
[Enum.KeyCode.A.Name] == false,
[Enum.KeyCode.S.Name] == false,
[Enum.KeyCode.D.Name] == false,
}

event:FireServer(dictionary)

-- server script

local event = game.Workspace:WaitForChild("Event")

event.OnServerEvent:connect(function(player, dictionary)
if dictionary[Enum.KeyCode.W.Name] == false then
print("ok")
end
end)


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