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

Does a disabled script still listen for remote events and fire when re-enabled?

Asked by 5 years ago

In my game, when players are put into teams they are given a clone of a script that is initially disabled but is re-enabled when given. This script listens for remote events that basically display a GUI when their team wins or loses, and displays a game result GUI that covers the screen.

When one team wins, events are fired like this from a server script:

Ghostvictoryevent:FireAllClients() --Any player on the ghosts team has a script inside them that listens for this, when it is activated it displays a gui that says "Mission Success" and then displays a game result screen a few seconds after. Only players that were put on the Ghost team have that script inside of them, and will be affected by this event.

SFfailureevent:FireAllClients() -- Same thing, but for the other team.

Any player that is in the current round will have their team script inside of them for the remote events to affect them, this announces that the game is over, mid-game announcements, and displays the match results.

When a player is left to spectate, meaning they sit out while the others play a round, the spectator is not given a script so any remote event fired from the server to display the winner and game results will that affect the spectator.

The issue is when the spectator plays the next round and is given the script, it seems that all the remote events that were called from last round happen at once and only towards that player.

Is this because even though the script is disabled, it still listens for remote events? And when it is re-enabled it does whatever the remote event said to do if the client that is given the script was not around to be affected by the event?

It seems like that might be what is happening but it doesn't make sense that a disabled script would still listen for remote events. If this is the cause, is there a way to keep it from doing that? If its not the cause then I'll have to figure out what really is the cause.

Thank you in advance!

Here is one of the scripts that is cloned, parented to the player, and re-enabled.

01local Players = game:GetService("Players")
02local ReplicatedStorage = game:GetService("ReplicatedStorage")
03local Player = Players.LocalPlayer
04local GhostVictory = ReplicatedStorage:WaitForChild("GhostVictoryEvent")
05local RoundTime = ReplicatedStorage:WaitForChild("RoundTimeEvent")
06local GhostFailure = ReplicatedStorage:WaitForChild("GhostFailureEvent")
07local PlantedA = ReplicatedStorage:WaitForChild("APlantedEvent")
08local PlantedB = ReplicatedStorage:WaitForChild("BPlantedEvent")
09local GhostCount = ReplicatedStorage:WaitForChild("GhostCountEvent")
10local SFCount = ReplicatedStorage:WaitForChild("SFCountEvent")
11local BombDroppedAlert = ReplicatedStorage:WaitForChild("BombDropAlertEvent")
12local GameEnd = ReplicatedStorage:WaitForChild("GameEndEvent")
13local RoundStart = ReplicatedStorage:WaitForChild("RoundStartEvent")
14local StarterGui = game:GetService('StarterGui')
15 
View all 92 lines...
0
shorten to 20 words or less im deaf Fifkee 2017 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

A disabled script does not listen for remote events or remote functions, which means it also wont fire these when the script is re-enabled UNLESS if something calls for it WHEN it is enabled.

Ad

Answer this question