D3M3N73D
|
  |
| Joined: 20 Jul 2010 |
| Total Posts: 232 |
|
|
| 02 Sep 2015 10:47 PM |
Passing arguments from server to client? Vice versa as shown on wiki works:
-- Inside Server Script local event1 = Instance.new("RemoteEvent") event1.Parent = game.Workspace event1.Name = "MyServerEvent1" event1.OnServerEvent:connect(function(player, arguments) print(player.Name .. " says: " .. arguments) end) local event2 = Instance.new("RemoteEvent") event2.Parent = game.Workspace event2.Name = "MyServerEvent2" event2.OnServerEvent:connect(function(player, arguments) print(player.Name .. " says: " .. arguments[1] .. " " .. arguments[2]) end)
-- Inside Local Script game.Workspace.MyServerEvent1:FireServer("Hello") game.Workspace.MyServerEvent2:FireServer({"Hello", "World!"})
But if I reverse it to fire client it says it's unable to cast object value? |
|
|
| Report Abuse |
|
|
ShungTzu
|
  |
| Joined: 14 Jun 2014 |
| Total Posts: 959 |
|
| |
|
|
| 02 Sep 2015 10:58 PM |
why in hell are you using a table you cant tostring a table you must index it first and concatenate it and then put it in print
https://www.youtube.com/watch?v=KmtzQCSh6xk&t=62s |
|
|
| Report Abuse |
|
|
D3M3N73D
|
  |
| Joined: 20 Jul 2010 |
| Total Posts: 232 |
|
|
| 02 Sep 2015 11:02 PM |
Really all I did was reverse it to test it..
-- Local Script game.ReplicatedStorage.eventTest.OnClientEvent:connect(function(player, arguments) print(player.Name .. " says: " .. arguments[1] .. " " .. arguments[2]) end);
-- Script game.ReplicatedStorage.eventTest:FireClient({"Hello", "World!"})
23:01:21.070 - Unable to cast value to Object |
|
|
| Report Abuse |
|
|
D3M3N73D
|
  |
| Joined: 20 Jul 2010 |
| Total Posts: 232 |
|
| |
|
D3M3N73D
|
  |
| Joined: 20 Jul 2010 |
| Total Posts: 232 |
|
|
| 02 Sep 2015 11:03 PM |
| Erm, just following the wiki. Lol... |
|
|
| Report Abuse |
|
|
D3M3N73D
|
  |
| Joined: 20 Jul 2010 |
| Total Posts: 232 |
|
|
| 02 Sep 2015 11:11 PM |
| I'm guessing this is too nubish of a request lol. |
|
|
| Report Abuse |
|
|
ShungTzu
|
  |
| Joined: 14 Jun 2014 |
| Total Posts: 959 |
|
|
| 02 Sep 2015 11:15 PM |
game.ReplicatedStorage.eventTest.OnClientEvent:connect(function(player, arguments)
"player", there, is not passed to a client(the server is not a player). |
|
|
| Report Abuse |
|
|
D3M3N73D
|
  |
| Joined: 20 Jul 2010 |
| Total Posts: 232 |
|
|
| 02 Sep 2015 11:19 PM |
Even without player it still throws the cast error.
-- Script game.ReplicatedStorage.eventTest:FireClient({"Hello", "World!"})
-- Local Script game.ReplicatedStorage.eventTest.OnClientEvent:connect(function(arguments) print(arguments[1] .. " " .. arguments[2]) end); |
|
|
| Report Abuse |
|
|
D3M3N73D
|
  |
| Joined: 20 Jul 2010 |
| Total Posts: 232 |
|
|
| 02 Sep 2015 11:27 PM |
| Is something wrong with my Studio? x: |
|
|
| Report Abuse |
|
|
ShungTzu
|
  |
| Joined: 14 Jun 2014 |
| Total Posts: 959 |
|
|
| 02 Sep 2015 11:34 PM |
No, you have to tell it which client to fire.
The first argument should be a Player object. |
|
|
| Report Abuse |
|
|
D3M3N73D
|
  |
| Joined: 20 Jul 2010 |
| Total Posts: 232 |
|
|
| 02 Sep 2015 11:40 PM |
-- Script game.Players.PlayerAdded:connect(function(Player) game.ReplicatedStorage.eventTest:FireClient({Player, "Hello", "World!"}) end);
-- Local Script game.ReplicatedStorage.eventTest.OnClientEvent:connect(function(Player, arguments) print(arguments[1] .. " " .. arguments[2]) end);
Still the same error.. :( |
|
|
| Report Abuse |
|
|
D3M3N73D
|
  |
| Joined: 20 Jul 2010 |
| Total Posts: 232 |
|
| |
|
D3M3N73D
|
  |
| Joined: 20 Jul 2010 |
| Total Posts: 232 |
|
|
| 02 Sep 2015 11:58 PM |
| Taking the arguments out of the table returns no output. Really scratching my head on this, can someone please help? |
|
|
| Report Abuse |
|
|
ShungTzu
|
  |
| Joined: 14 Jun 2014 |
| Total Posts: 959 |
|
|
| 03 Sep 2015 12:04 AM |
Server script:
for i,player in pairs (game.Players:GetPlayers()) do workspace.event:FireClient(player, "one",script.Parent.Name,3) end
LocalScript:
workspace.event.OnClientEvent:connect(function(a,b,c) print(a,b,c) end)
Output on client:
one ServerScriptService 3 |
|
|
| Report Abuse |
|
|
D3M3N73D
|
  |
| Joined: 20 Jul 2010 |
| Total Posts: 232 |
|
|
| 03 Sep 2015 12:10 AM |
| I did exactly that but still no output. Also, I tried that.. >.< So i'm really thinking it is my Studio. |
|
|
| Report Abuse |
|
|
D3M3N73D
|
  |
| Joined: 20 Jul 2010 |
| Total Posts: 232 |
|
|
| 03 Sep 2015 12:13 AM |
I doubt these warnings make a difference, but...
00:12:47.077 - Mode 2 failed: "Unable to create D3D device: 887a0004" 00:12:47.079 - Trying mode 3... 00:12:48.306 - StarterGui:RegisterSetCore is not yet enabled 00:12:48.307 - StarterGui:RegisterGetCore is not yet enabled 00:12:48.308 - StarterGui:RegisterSetCore is not yet enabled 00:12:48.308 - StarterGui:RegisterGetCore is not yet enabled 00:12:49.678 - StarterGui:RegisterSetCore is not yet enabled |
|
|
| Report Abuse |
|
|
D3M3N73D
|
  |
| Joined: 20 Jul 2010 |
| Total Posts: 232 |
|
|
| 03 Sep 2015 12:58 AM |
| Any ideas as to why this isn't working? I have to pass args to the client. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 03 Sep 2015 01:29 AM |
game.ReplicatedStorage.eventTest.OnClientEvent:connect(function(arguments) print("Server says: " .. arguments[1] .. " " .. arguments[2]) end);
-- Script game.ReplicatedStorage.eventTest:FireClient(game.Players.Player1, {"Hello", "World!"}) |
|
|
| Report Abuse |
|
|