So I am pretty sure you can :FireClient to fire the event but how would I make something that happens when its fired? Is that what its used for?
I have already read that I just wanted someone to explain it in a more simple way. I DID search it so…
Use remoteEvent.OnServerEvent
when the event has fired from a local script and use remoteevent.OnClientEvent
when the event is fired from a server script
So how would I make it so I fired it on script one, and when it was fired it told script 2 to delete itself?
Local script
Remote.OnClientEvent:Connect(function()
--delete a script, but only the player can't see the script since this is a local script
end)
So something like this?
local BlurEvent = game.ReplicatedStorage.Events.BlurEvents
BlurEvent.OnClientEvent:Connect(function()
game.Workspace.Script:Destroy()
end)
You could just use workspace.Script
But is that script correct, would it work?
Where do you fire it from?
Edit: It would work but you need to fire it somewhere
Sorry for the late reply! @mineman_28, heres an example:
script one:
local BlurEvent = game.ReplicatedStorage.Events.BlurEvents
BlurEvent.OnClientEvent:Connect(function()
game.Workspace.Script:Destroy()
end)
script 2:
script 3:
game.ReplicatedStorage.Events.BlurEvents.OnClientEvent:Connect(function)
this would delete script 2 (In workspace) right?
No, because with events, you must connect a local script with a script, and if you want to delete a script from a script, you would do it like this workspace.Script:Destroy()
You could use script:Destroy
, (shortcut).
But if you want to do something else then this is how it works
Local Script
game:GetService(“ReplicatedStorage”):WaitForChild(the event):FireServer()
But the problem is, if you’d do it on a script you would need to get the player, except if you want to fire all of them with FireAllClients()
Script
game:GetService(“ReplicatedStorage”):WaitForChild(the event).OnServerEvent:Connect(function()
end)
No, that wouldn’t work for a lot of reasons. Please look into the relevant wiki page dedicated to remote events and functions, and use the search bar!
Remote events are used to communicate between the server and the client and are used to send information. Some actions can only be performed by the server and others by the client. That is why they are useful when it comes to handling communication between the server and the client to do specific actions.
A remote event can only perform a one way communication. That is from "Server to Client, “Client to Server”, “Client to Client” and “Server to all Clients”.
Here are some terms that you should know…
“FireAllClients”
“FireClient”
Given by the name, they do exactly that. The FireClient functions sends a remote event to a specific player or players. This methods requires an argument with the player object(the player) when communicating between server and the client.
FireAllClients is pretty self explanatory. Unlike FireClient, this method ignores the need to call
a specific player and sends a remote event to all clients connected by the server.
“OnServerEvent” is another term that listens to and retrieve events fired by the client, and is intended for the server. This term simply is used for communicating between the client and the server.
“OnClientEvent” is also another term that is only ever used on the client. It listens for the event sent from the server, and communicates from server to client. This method is listens to functions sent by the server, and is recieved by the client in a local script.
That is a brief explanation of remote events. @mineman_28 method works.
Also, dont you dare say you couldn’t find anything about remote events.
Haha the last sentence was amazing
Also, dont you dare say you couldn’t find anything about remote events.
That last sentence though. But I couldn’t find any- nah I found a good page.
Remote Events are used to communicate between Client & Server & All clients.
oh ok. I get it way more now…