Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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

0
you can make a clone of one local script for each player and parent them to each player. Trew86 175 — 5y
0
i tried cloning it to playerscripts it didnt work TheRobuxMaster5M -10 — 5y
0
Toggle their Disabled property. DeceptiveCaster 3761 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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.

Ad
Log in to vote
0
Answered by
chomboghai 2044 Moderation Voter Community Moderator
5 years ago

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.

Answer this question