Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is it possible to execute a local script from a normal script???

Is it possible to make a LocalScript execute on all clients from a Server Script?

3 comments

0

you can make a clone of one local script for each player and parent them to each player.

0

i tried cloning it to playerscripts it didnt work

0

Toggle their Disabled property.

2 answers

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.