Medkit Script Like Field Trip Z or Break In

Alright guys so I am trying to make a script where you can heal yourself or other players with a medkit similar to a story game system like ftz or break in. here is the script I have so far its a local script in the tool.


-- Create the Heal function
local function Heal(player)
	-- Check if the player is alive
	if player.Character and player.Character:FindFirstChild("Humanoid") and player.Character.Humanoid.Health > 0 then
		-- Create a selection box on the player
		local selectionBox = Instance.new("SelectionBox")
		selectionBox.Adornee = player.Character
		selectionBox.LineThickness = 0.1
		selectionBox.Parent = player.Character
		
		-- Wait for a short duration to show the selection box
		wait(1)
		
		-- Heal the player
		player.Character.Humanoid.Health = player.Character.Humanoid.MaxHealth
		
		-- Remove the selection box
		selectionBox:Destroy()
	end
end

-- Handle equipped event
tool.Equipped:Connect(function(mouse)
	-- Create a selection box for the local player
	local selectionBox = Instance.new("SelectionBox")
	selectionBox.Adornee = game.Players.LocalPlayer.Character
	selectionBox.LineThickness = 0.1
	selectionBox.Parent = game.Players.LocalPlayer.Character
	
	-- Wait for a short duration to show the selection box
	wait(1)
	
	-- Remove the selection box
	selectionBox:Destroy()
end)

-- Handle mouse button click
tool.Activated:Connect(function()
	-- Check if the player is healing themselves
	local humanoid = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")
	if humanoid and humanoid.Health > 0 then
		Heal(game.Players.LocalPlayer)
	end
end)
3 Likes

Well what do you want us to help you with? If you are looking for a review of your code move the topic to #help-and-feedback:code-review

1 Like

im looking to fix the script, it dosent work properly and i need help fixing it.

1 Like

Well, what’s the issue? You have to specify it for us to help u

1 Like

the entire script isnt working properly, no output either.

1 Like