Hello.
This localscript won't run again after the player resets. Therefore, the serverscript won't run because the event isn't fired.
How can you keep the localscript running, or at least, restarting, after resetting/dying?
UIS = game:GetService("UserInputService")
player = game.Players.LocalPlayer
inrange = false
dead = false
player.CharacterAdded:Connect(function()
repeat wait() until player.Character
dead = false
local bloodstain = game.Workspace:FindFirstChild(player.Name.."_Bloodstain")
if bloodstain ~= nil then
while wait() do
local magnitude = (player.Character.UpperTorso.Position - bloodstain.Position).Magnitude
if magnitude <= 8 and not dead then
inrange = true
script.Parent.Visible = true
else
inrange = false
script.Parent.Visible = false
end
end
end
end)
player.CharacterAdded:Connect(function()
repeat wait() until player.Character
player.Character.Humanoid.Died:Connect(function()
print(player.Name.." died")
dead = true
game.ReplicatedStorage.Events.died_event:FireServer(player)
end)
end)
UIS.InputBegan:Connect(function(input,processed)
if not processed then
if input.UserInputType == Enum.UserInputType.Keyboard and inrange then
local key = input.KeyCode
if key == Enum.KeyCode.E then
script.Parent.Visible = false
game.ReplicatedStorage.Events.retreive_souls:FireServer(player)
end
end
end
end)
If you need to see what is happening, you can search my name on Roblox and find my game called "Dead Souls". If you're trying it, please test out this script by resetting your character. Thank you for reading.

2 comments
Place the local script in the 'StarterPlayerScripts` folder (under StarterPlayer folder)
Why is this all happening in a local script in the first place? This is a lot of power given to the client https://www.robloxdev.com/articles/Game-Security#server-side-validation