Advertisement
tyridge77

FE_Server

Aug 25th, 2015
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.49 KB | None | 0 0
  1. --SERVER
  2.  
  3.  
  4. -- So, as you saw in the previous example,
  5. -- .OnServerEvent:connect(function) is used when a client is trying to have the server do something.
  6.  
  7. -- However, say we cast a spell at someone, and it hit them.
  8. -- Now the logical thing to do would be to make sure that all clients that are in the area
  9. -- play a local spell effect at that position on their screen. (See, this is where the power of filtering enabled comes.
  10. -- completely localized effects and absolute control over what goes on in the client and the server, as to prevent lag.
  11.  
  12. -- Anyways, so initially we want to send a message from the client to the server saying,
  13. -- "Hey, I hit this guy. Let all clients(including mine) know that by creating a spell effect and rendering it on their screens."
  14.  
  15. -- Then the server is going to take that message, and send a message back to all clients notifying them to
  16. -- render the spell effect.
  17.  
  18.  
  19. -- Here we're going to instance our remote event, used for communication.
  20.  
  21. RunSpellEffect = Instance.new("RemoteEvent",Workspace);
  22. RunSpellEffect.Name = "RunSpellEffect";
  23.  
  24.  
  25.  
  26. function SpellEffects(player,cframe,effectname)
  27.    print("Spell collided at ",cframe,". Effect name: ",effectname);
  28.    print("Sending information to all clients so they can deal with it accordingly.")
  29.  
  30.    RunSpellEffect:FireAllClients(cframe,effectname); -- FireAllClients() invokes the client's .OnClientEvent event.
  31. end
  32.  
  33.  
  34.  
  35. RunSpellEffect.OnServerEvent:connect(SpellEffects) -- Message from client to server
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement