I am currently trying to make a system so that alive players can revive someone if they get to them before a timer runs out. I am trying to make all of the proximity prompts to revive delete on the client side so that the player who is dead cannot revive themself or others. The issue is that this doesn’t happen when the player dies. I have tried using remote events but I am inexperienced with using them. I have also tried putting the loop in the original script but that also didn’t work. Here is the script that fires the remote event:
local Character = script.Parent
local Value = Character.Value
local Player = game.Players:GetPlayerFromCharacter(Character)
local Animations = Character:FindFirstChild("Animate")
local Spectate = Player.PlayerGui.Spectate
local ReplicatedStorage = game:GetService("ReplicatedStorage")
table.insert(_G.AlivePlyrs, Character)
local Outline = Instance.new("Highlight")
Outline.Parent = Character
Outline.FillTransparency = 1
Outline.OutlineColor = Color3.new(1,0,0)
Outline.OutlineTransparency = 1
Value:GetPropertyChangedSignal("Value"):Connect(function()
if Value.Value == 1 then
local Revive = Instance.new("ProximityPrompt")
Revive.Parent = Character
Revive.Name = "Revive"
Revive.ActionText = "Revive"
Revive.HoldDuration = 0.1
Revive.KeyboardKeyCode = Enum.KeyCode.R
Revive.UIOffset = Vector2.new(0, 40)
Revive.MaxActivationDistance = 7.5
ReplicatedStorage.DelProxPrompts:FireAllClients()
print("Sent")
Outline.OutlineTransparency = 0
local pos = table.find(_G.AlivePlyrs, Character)
table.remove(_G.AlivePlyrs, pos)
Animations.idle.Animation1.AnimationId = "https://www.roblox.com/asset/?id=119027085796995"
Player.CameraMaxZoomDistance = 20
Character.Humanoid.WalkSpeed = 4
Player.PlayerGui.TimerDeath.Enabled = true
else
if Value.Value == 0 then
Outline.OutlineTransparency = 1
table.insert(_G.AlivePlyrs, Character)
Player.CameraMaxZoomDistance = 0.5
Character.Humanoid.WalkSpeed = 16
Spectate.Enabled = false
else
if Value.Value == 2 then
Spectate.Enabled = true
end
end
end
end)
Here is the script that receives the remote event:
local Players = game:GetService("Players")
local LPlayer = Players.LocalPlayer
local Character = LPlayer.Character or LPlayer.CharacterAdded:Wait()
local Val = Character:WaitForChild("Value")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local function DelProx()
print("retrieved")
if Val.Value ~= 0 then
print("true")
for i, v in pairs(Players:GetPlayers()) do
if v.Character:WaitForChild("Value") == 1 then
local Rev = v.Character:WaitForChild("Revive")
Rev:Destroy()
end
end
end
end
ReplicatedStorage.DelProxPrompts.OnClientEvent:Connect(DelProx())