##Main Problem
I am making a round script that uses a Remote Event (Client --> Server). When the player dies, it just doesn't fire again. How can I go around this?
Server
--\\ Services
local repStorage = game:GetService("ReplicatedStorage")
--\\ Network Data
local remoteEvent = repStorage:WaitForChild("RemoteEvent")
--\\ Remote Event Example
remoteEvent:FireAllClients()
Client
--\\ Services
local repStorage = game:GetService("ReplicatedStorage")
--\\ Network Data
local remoteEvent = repStorage:WaitForChild("RemoteEvent")
--\\ Remote Example
remoteEvent.OnClientEvent:Connect(function() -- Player dies, doesn't fire
while wait() do
print("oof")
end
end)
##A Solution I Thought Of
Instead of an anonymous event, I could use functions and make a separate line that listens for the event. I will do that again but that line will be wrapped by an anonymous event:
Client
--\\ Services
local repStorage = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
--\\ Player Components
local player = players.LocalPlayer
--\\ Character Components
local char = player.Character
local hum = char:WaitForChild("Humanoid")
--\\ Network Data
local remoteEvent = repStorage:WaitForChild("RemoteEvent")
--\\ Remote Example
local function onClientEvent()
while wait() do
print("oof")
end
end
remoteEvent.OnClientEvent:Connect(onClientEvent)
hum.Died:Connect(function()
remoteEvent.OnClientEvent:Connect(onClientEvent)
end)
The server is the same
But, that did nothing, the same thing happened.
I cannot think of any other solution.

2 comments
Mabe you can make a function to remove script when plr dies? With humanoid health?
Why would I want to destroy the script if I want it to continue?