✓ Accepted answer
local nm = script.Parent.uName.Text
local hp = script.Parent.uHP.Text
Here, nm and hp are being set to the value of whatever the text of uName and uHP is.
hp = mP.Parent.Humanoid.Health
nm = mP.Parent.Name
This just changes the string value that hp and nm have, not the text of gui.
nm and hp should instead equal the actual gui instance.
mP is set to the value mouse's target before there is a target and mP is never updated with the new mouse target.
local p = game.Players.LocalPlayer
local mouse = p:GetMouse()
local mP = mouse.Target
local nm = script.Parent.uName
local hp = script.Parent.uHP
mouse.Move:connect(function()
mP = mouse.Target
if mP then
print "mp"
if mP.Parent:FindFirstChild("Humanoid") or mP.Parent:FindFirstChild("TowerHumanoid") then
print(mP.Parent.Name)
hp.Text = mP.Parent.Humanoid.Health
nm.Text = mP.Parent.Name
end
end
end)
3 comments
Your script must be in a local script.
It is a local script, inside a gui ,located in startergui
Please explain what you're trying to accomplish and make your question title relevant to the content.