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: Remote Event, need help going from server to local

Previous Thread :: Next Thread 
Raildex is not online. Raildex
Joined: 06 Dec 2009
Total Posts: 934
12 Mar 2016 04:48 PM
So what i need to do here is that when a ship dies (my function below), script.Parent.ShipHumanoid.Changed:connect(function()
if script.Parent.ShipHumanoid.Health <= 0 then

it will trigger a function in the players gui that will change text, it needs to pass the values script.Parent.Name and script.Parent.Parent.Parent.Name


( the localscript's location is PlayerGui.SideBar.main.Cain <-Cain is the scripts parent)

it needs to then check in the local script in the gui if the second passed value (script.Parent.Parent.Parent.Name) is the same as the script.Parent.Parent.teamName.Value

how do I do this, I know how to go from local to server but not the other way around.
Report Abuse
jode6543 is not online. jode6543
Joined: 16 Jun 2009
Total Posts: 5363
12 Mar 2016 04:59 PM
--On the server
local remote = game.ReplicatedStorage.SomeRemoteEvent --replace this
script.Parent.ShipHumanoid.Changed:connect(function()
if script.Parent.ShipHumanoid.Health <= 0 then
remote:FireClient(playerReceivingEvent, script.Parent.Name, script.Parent.Parent.Parent.Name)
end
end)

Or, if you want all players to receive the event:
remote:FireAllClients(script.Parent.Name, script.Parent.Parent.Parent.Name)

--On the client
local remote = game.ReplicatedStorage.SomeRemoteEvent
remote.OnClientEvent:connect(function(name1, name2)
--do stuff
end)

Also, if you are unaware, you can access the API documentation on the Wiki for pretty much every instance: http://wiki.roblox.com/index.php?title=API:Class/RemoteEvent
Report Abuse
Raildex is not online. Raildex
Joined: 06 Dec 2009
Total Posts: 934
12 Mar 2016 05:10 PM
Yeah I had gone to the Wiki and read through it but I just couldnt grasp it for locals. So if I did
remote:FireClient(script.Parent.Parent.Parent.OwnerName.Value, script.Parent.Name, script.Parent.Parent.Parent.Name) it would only go to the local script of the specified player?
Report Abuse
jode6543 is not online. jode6543
Joined: 16 Jun 2009
Total Posts: 5363
12 Mar 2016 05:53 PM
That's correct.
Report Abuse
Raildex is not online. Raildex
Joined: 06 Dec 2009
Total Posts: 934
12 Mar 2016 06:19 PM
it didnt work, I found that I need to go it a player object?
Report Abuse
Raildex is not online. Raildex
Joined: 06 Dec 2009
Total Posts: 934
12 Mar 2016 06:55 PM
remote:FireClient(game.Players[script.Parent.Parent.Parent.OwnerName.Value],deathText)

I changed it to that and it works in studio testing but when run on a server it says that it is not a valid member of players?
Report Abuse
jode6543 is not online. jode6543
Joined: 16 Jun 2009
Total Posts: 5363
12 Mar 2016 07:09 PM
You'll want to check that the player actually exists first:

local player = game.Players:FindFirstChild(script.Parent.Parent.Parent.OwnerName.Value)
if player then
remote:FireClient(player, deathText)
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