Help with revive system

I’m making a revive system, that uses proximity prompt. But i need help, because i don’t know how to check if who clicked the proximity prompt, it’s the current player downed, or the other players.

Here’s my code (Updated):

Client:

local Player = game.Players.LocalPlayer
local Humanoid : Humanoid = Player.Character:WaitForChild("Humanoid")
local FootstepsSounds = script:WaitForChild("Footsteps")
local InjuredAnimation = script:WaitForChild("Injured")
local InjuredAnimationTrack = Humanoid:LoadAnimation(InjuredAnimation)
local DownedAnimation = script:WaitForChild("Downed")
local DownedAnimationTrack = Humanoid:LoadAnimation(DownedAnimation)
local HumanoidSpeed = Humanoid.WalkSpeed
local RunService = game:GetService("RunService")
local DownSystem = game:GetService("ReplicatedStorage").Events:FindFirstChild("DownSystem")

function Cancel()
	InjuredAnimationTrack:Stop()			
	DownedAnimationTrack:Stop()
	Humanoid.JumpPower = 50
	Humanoid.WalkSpeed = HumanoidSpeed
	if Player.Character:FindFirstChild("RevivePrompt") then
		Player.Character:FindFirstChild("RevivePrompt"):Destroy()
	end
end

--[[function Revive(Prompt: ProximityPrompt)
	Prompt.Triggered:Connect(function(player)
		--idk what to put here
	end)
end--]]

function CreatePrompt()
	DownSystem:FireServer("CreatePrompt")
end

function Down()
	DownedAnimationTrack:Play()
	InjuredAnimationTrack:Stop()
	Humanoid.WalkSpeed = 0.5
	Humanoid.JumpPower = 0
	CreatePrompt()
end

function Injure()
	InjuredAnimationTrack:Play()
	DownedAnimationTrack:Stop()
	Humanoid.WalkSpeed = 3.8
	Humanoid.JumpPower = 30
end

Humanoid.HealthChanged:Connect(function(health)
	if health <= 35 and not (health < 9) then
		Injure()
	elseif health <= 8 then
		Down()
	else
		Cancel()
	end
end)

Server: (New)

local DownSystem = game:GetService("ReplicatedStorage").Events:FindFirstChild("DownSystem")

function CreatePrompt(Player)
	local RevivePrompt = Instance.new("ProximityPrompt")
	RevivePrompt.Parent = Player.Character
	RevivePrompt.Name = "RevivePrompt"
	RevivePrompt.ActionText = "Revive"
	RevivePrompt.ObjectText = Player.Name
end

DownSystem.OnServerEvent:Connect(function(Player, Value)
	if Value == "CreatePrompt" then
		CreatePrompt(Player)
	end
end)
function CreatePrompt(Player)
	local RevivePrompt = Instance.new("ProximityPrompt")
	RevivePrompt.Parent = Player.Character
	RevivePrompt.Name = "RevivePrompt"
	RevivePrompt.ActionText = "Revive"
	RevivePrompt.ObjectText = Player.Name

    RevivePrompt.Triggered:Connect(function(Target)
        if (Target ~= Player) then 
            --// revive 
        end
    end)
end
1 Like

Thanks, it works now!

you know what it is, LIMIT WORD, no wait, limit?

Okay, now the problem is: for some reason, when i try to remove the prompt after the player get’s injured again (not downed), it for some reason just bug and it just… loop? ok, here’s my script:

Server:

local DownSystem = game:GetService("ReplicatedStorage").Events:FindFirstChild("DownSystem")

function CreatePrompt(Player)
	local RevivePrompt = Instance.new("ProximityPrompt")
	RevivePrompt.Parent = Player.Character
	RevivePrompt.Name = "RevivePrompt"
	RevivePrompt.ActionText = "Revive"
	RevivePrompt.ObjectText = Player.Name

	RevivePrompt.Triggered:Connect(function(Target)
		if (Target ~= Player) then 
			Player.Character.Humanoid.Health += 50
		end
	end)
end

function DestroyPrompt(Player: Player)
	if Player.Character:FindFirstChild("RevivePrompt") then
		Player.Character:FindFirstChild("RevivePrompt"):Destroy()
		print("Removed prompt.")
	end
end

DownSystem.OnServerEvent:Connect(function(Player, Value)
	if Value == "CreatePrompt" then
		CreatePrompt(Player)
	elseif Value == "RetrievePrompt" then
		DestroyPrompt(Player)
	end
end)

Client:

local Player = game.Players.LocalPlayer
local Humanoid : Humanoid = Player.Character:WaitForChild("Humanoid")
local FootstepsSounds = script:WaitForChild("Footsteps")
local InjuredAnimation = script:WaitForChild("Injured")
local InjuredAnimationTrack = Humanoid:LoadAnimation(InjuredAnimation)
local DownedAnimation = script:WaitForChild("Downed")
local DownedAnimationTrack = Humanoid:LoadAnimation(DownedAnimation)
local HumanoidSpeed = Humanoid.WalkSpeed
local RunService = game:GetService("RunService")
local DownSystem = game:GetService("ReplicatedStorage").Events:FindFirstChild("DownSystem")

function Cancel()
	InjuredAnimationTrack:Stop()			
	DownedAnimationTrack:Stop()
	Humanoid.JumpPower = 50
	Humanoid.WalkSpeed = HumanoidSpeed
	DownSystem:FireServer("RetrievePrompt")
end

--[[function Revive(Prompt: ProximityPrompt)
	Prompt.Triggered:Connect(function(player)
		--idk what to put here
	end)
end--]]

function Down()
	DownedAnimationTrack:Play()
	InjuredAnimationTrack:Stop()
	Humanoid.WalkSpeed = 0.5
	Humanoid.JumpPower = 0
	DownSystem:FireServer("CreatePrompt")
end

function Injure()
	DownSystem:FireServer("RetrievePrompt")
	InjuredAnimationTrack:Play()
	DownedAnimationTrack:Stop()
	Humanoid.WalkSpeed = 3.8
	Humanoid.JumpPower = 30
end

Humanoid.HealthChanged:Connect(function(health)
	if health <= 35 and not (health <= 8) then
		Injure()
	elseif health <= 8 then
		Down()
	else
		Cancel()
	end
end)

And also, for some reason, if i print something in the output, this happens:
Screenshot_1
And i don’t know why it prints 7 times this.