Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --SERVER
- -- So, as you saw in the previous example,
- -- .OnServerEvent:connect(function) is used when a client is trying to have the server do something.
- -- However, say we cast a spell at someone, and it hit them.
- -- Now the logical thing to do would be to make sure that all clients that are in the area
- -- play a local spell effect at that position on their screen. (See, this is where the power of filtering enabled comes.
- -- completely localized effects and absolute control over what goes on in the client and the server, as to prevent lag.
- -- Anyways, so initially we want to send a message from the client to the server saying,
- -- "Hey, I hit this guy. Let all clients(including mine) know that by creating a spell effect and rendering it on their screens."
- -- Then the server is going to take that message, and send a message back to all clients notifying them to
- -- render the spell effect.
- -- Here we're going to instance our remote event, used for communication.
- RunSpellEffect = Instance.new("RemoteEvent",Workspace);
- RunSpellEffect.Name = "RunSpellEffect";
- function SpellEffects(player,cframe,effectname)
- print("Spell collided at ",cframe,". Effect name: ",effectname);
- print("Sending information to all clients so they can deal with it accordingly.")
- RunSpellEffect:FireAllClients(cframe,effectname); -- FireAllClients() invokes the client's .OnClientEvent event.
- end
- RunSpellEffect.OnServerEvent:connect(SpellEffects) -- Message from client to server
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement