Is it possible to make a LocalScript execute on all clients from a Server Script?
Yes, it is possible. This can be done through RemoteFunctions and RemoteEvents.
An example would be putting a RemoteEvent in the ReplicatedStorage, setting up an event in your LocalScript, and firing it through your server script.
-- LocalScript local ReplicatedStorage = game:GetService("ReplicatedStorage") local Event = ReplicatedStorage:WaitForChild("RemoteEvent") Event.OnClientEvent:Connect(function(args) -- Do something end)
And then your server script would look something like:
-- Server script local ReplicatedStorage = game:GetService("ReplicatedStorage") local Event = ReplicatedStorage:WaitForChild("RemoteEvent") local Args -- Provide your arguments Event:FireAllClients(args)
You asked to fire the event on all clients, but you can use RemoteEvent:FireClient(player)
to fire on a specific player.
You can use a remoteEvent to trigger a signal that will cause all listening scripts to perform a specific action.
You can fire the remoteEvent
from the server and on whichever localscript you choose, you can set up a listener to the event and run a function upon firing of the signal.