Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

GUI Hide name button?

local player = game.Players.LocalPlayer
local Character = player.Character
Hidden = false

script.Parent.MouseButton1Click:connect(function()
	if Hidden == false then
		Character.Humanoid.HealthDisplayDistance = 0
		Character.Humanoid.NameDisplayDistance = 0
		Hidden = true
		script.Parent.Text = "Show Name"
		
	else
		Character.Humanoid.HealthDisplayDistance = 100
		Character.Humanoid.NameDisplayDistance = 100
		Hidden = false
		script.Parent.Text = "Hide Name"
		
	end
end)

script.Parent.TouchTap:connect(function()
	if Hidden == false then
		Character.Humanoid.HealthDisplayDistance = 0
		Character.Humanoid.NameDisplayDistance = 0
		Hidden = true
		
	else
		Character.Humanoid.HealthDisplayDistance = 100
		Character.Humanoid.NameDisplayDistance = 100
		Hidden = false
		
	end
end)

what's the problem? Doesn't give me an output for some reason, or perhaps I simply missed it.

1 comment

0

This had an answer.. then.. it disappeared.

2 answers

✓ Accepted answer

NameDisplayDistance and HealthDisplayDistance are apart of Player

So change Character.Humanoid to player.

Your Problem is you are using the Character's Humanoid instead of the LocalPlayer, Now lets import it to your script.

local player = game.Players.LocalPlayer
local Character = player.Character
Hidden = false

script.Parent.MouseButton1Click:connect(function()
    if Hidden == false then
        player.HealthDisplayDistance = 0
        player.NameDisplayDistance = 0
        Hidden = true
        script.Parent.Text = "Show Name"

    else
        player.HealthDisplayDistance = 100
        player.NameDisplayDistance = 100
        Hidden = false
        script.Parent.Text = "Hide Name"

    end
end)

script.Parent.TouchTap:connect(function()
    if Hidden == false then
        player.HealthDisplayDistance = 0
        player.NameDisplayDistance = 0
        Hidden = true

    else
        player.HealthDisplayDistance = 100
        player.NameDisplayDistance = 100
        Hidden = false

    end
end)

Hope this Helped.

This discussion is preserved as it was. New answers, comments, and votes are closed.