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
 

Can someone give me an example of.....

Previous Thread :: Next Thread 
D3M3N73D is not online. 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 is not online. ShungTzu
Joined: 14 Jun 2014
Total Posts: 959
02 Sep 2015 10:56 PM
Post your OnClientEvent.
Report Abuse
cpmoderator12345 is not online. cpmoderator12345
Joined: 26 Jan 2013
Total Posts: 15651
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 is not online. 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 is not online. D3M3N73D
Joined: 20 Jul 2010
Total Posts: 232
02 Sep 2015 11:02 PM
I'm not using a table?
Report Abuse
D3M3N73D is not online. D3M3N73D
Joined: 20 Jul 2010
Total Posts: 232
02 Sep 2015 11:03 PM
Erm, just following the wiki. Lol...
Report Abuse
D3M3N73D is not online. 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 is not online. 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 is not online. 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 is not online. D3M3N73D
Joined: 20 Jul 2010
Total Posts: 232
02 Sep 2015 11:27 PM
Is something wrong with my Studio? x:
Report Abuse
ShungTzu is not online. 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 is not online. 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 is not online. D3M3N73D
Joined: 20 Jul 2010
Total Posts: 232
02 Sep 2015 11:51 PM
Bump.
Report Abuse
D3M3N73D is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
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