See other players health

It only works when you’re closer than 10 studs from the player the mouse is pointing. Also only works with players, but I can make it work with NPCs if you want.

The script is supposed to be inside the frame.

im aware of that,

i posted my layout as you can see if i referenced something wrong, i put into starter character for a reason though

The script is supposed to be inside the frame, but I can move it to startercharacterscripts.
image

Nvm It was easy, just change the variable to the PlayerGui

local rs = game:GetService("RunService")
local mouse = game.Players.LocalPlayer:GetMouse()
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local plrUI = plr:WaitForChild("PlayerGui")
local maxDist = 10

local GUI = plrUI.GUI -- gui name
local frame = GUI.Frame
--local HPframe = frame.HealthBarFrame 
--local text = frame.NamePLR
1 Like

change or add? with the script that i posted, nothing useed player UI, so what do i change to player ui?
script:

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local ui = plr.PlayerGui:WaitForChild("PlayerHealth")
local frame = ui.Frame

local HPframe = plr.PlayerGui:WaitForChild("PlayerHealth").Frame.Frame
local text = frame.TextLabel
local maxDist = 10

rs.Heartbeat:Connect(function()
	local target = mouse.Target 
	if target then
		local CharTarget = game.Players:GetPlayerFromCharacter(target.Parent) -- bodypart
			or game.Players:GetPlayerFromCharacter(target.Parent.Parent) -- accessory

		if CharTarget then
			local head = CharTarget.Character:FindFirstChild("Head")
			if head then
				local dist = plr:DistanceFromCharacter(head.Position)
				if dist < maxDist then
					frame.Visible = true
					text.Text = CharTarget.Name
					local charTarget = CharTarget.Character
					HPframe.Size = UDim2.new(0,(charTarget.Humanoid.Health/charTarget.Humanoid.Health * 200),1,0)
				else
					frame.Visible = false
				end
			end
		else
			frame.Visible = false
		end
	end
end)

your completely just changing the variables without saying what you changed, or are adding them

1 Like

Oh, my bad, srry I didn’t see it there. I’ll recheck.
(I should’ve literally check :eyes:)

I believe that I have set the Enabled property of it to false, just enable it to true.

To hide it, you can either edit the script to enable it to true or false or just change the visible property on studio to true.

1 Like

i made the gui, i made everything but the script, so are you gonna answer this?

Since I don’t know what exactly is the problem, can you provide an rbxm file or place file of it and I’ll tell you the problem when I got it fixed?

Never mind, just do neither. I don’t think there’s anything wrong.

The only way to fix is to print after each condition and see if it prints, if it doesn’t, then you can either tell me or just fix it i guess.

dammit crictoli at least read my post

1 Like

All I’m doing is replying several times not knowing I was reading now I feel stupid LOL

1 Like