I'm trying to make a revival system for my game

I used this video to help me do my revival system, but I wanted my revive system to have medkits involved.
[How to make a REVIVE SYSTEM | ROBLOX STUDIO - YouTube]

So I reworked the script and it came out like this:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

Players.PlayerAdded:Connect(function(Player)
	local DeathCFrame = Instance.new("CFrameValue")
	DeathCFrame.Value = CFrame.new()
	DeathCFrame.Name = "DeathCFrame"
	DeathCFrame.Parent = Player
	
	Player.CharacterAdded:Connect(function(Character)
		if Player.DeathCFrame.Value ~= CFrame.new() then
			repeat task.wait() until Character:WaitForChild("HumanoidRootPart")
			Character.HumanoidRootPart.CFrame = Player.DeathCFrame.Value
			Player.DeathCFrame.Value = CFrame.new()
		end
		local Humanoid = Character.Humanoid
		Humanoid.BreakJointsOnDeath = false
		Humanoid.Died:Connect(function()
			Player.DeathCFrame.Value = Character.HumanoidRootPart.CFrame
			for _, v in pairs(Character:GetDescendants()) do
				if v:IsA("Motor6D") then
					local Attachment0, Attachment1 = Instance.new("Attachment"), Instance.new("Attachment")
					Attachment0.CFrame = v.C0
					Attachment1.CFrame = v.C1
					Attachment0.Parent = v.Part0
					Attachment1.Parent = v.Part1
					
					local BallSocketConstaint = Instance.new("BallSocketConstraint")
					BallSocketConstaint.Attachment0 = Attachment0
					BallSocketConstaint.Attachment1 = Attachment1
					BallSocketConstaint.Parent = v.Parent
					
					v:Destroy()
				end
			end
			local ProximityPrompt = Instance.new("ProximityPrompt")
			local MedKit = "MedKit"
			local localplr = game.Players.LocalPlayer
			
			if localplr.Backpack:FindFirstChild(MedKit) then
				ProximityPrompt.Parent = Character.HumanoidRootPart
				ProximityPrompt.ObjectText = Player.Name
				ProximityPrompt.ActionText = "Hold 'E' To Revive"
				ProximityPrompt.HoldDuration = 5
				ProximityPrompt.RequiresLineOfSight = false
				ProximityPrompt.Enabled = false
				task.wait(.25)
				ProximityPrompt.Enabled = true
				ReplicatedStorage.RemoteEvents.HealingHandler:FireClient(Player, "HidePrompt", ProximityPrompt)
				
			else
				print(Player.Name " does not have a MedKit")
			end
			
			
			ProximityPrompt.Triggered:Connect(function(TriggPlayer)
				if TriggPlayer.Character.Humanoid.Health >= 1 then
					Player:LoadCharacter()
					ProximityPrompt:Destroy()
				end
			end)
		end)
	end)
	Player:LoadCharacter()
end)

image

Can someone guide me on how to resolve this? I’m inexperienced in scripting.

You can’t use LocalPlayer in a server sided script. You already have the player with the PlayerAdded event. Change it to this

if Player.Backpack:FindFirstChild(MedKit) then
1 Like

Thank you! I have an issue with overthinking stuff so I preciate this. :joy:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.