|
| 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 |
|
|
| |
|
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 |
|
|
|
| 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 |
|
|
|
| 14 Jan 2016 01:04 AM |
| trash do u even know how to serialize table? |
|
|
| Report Abuse |
|
|
|
| 14 Jan 2016 01:08 AM |
| /\ stfu, I don't like you. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|