Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

GUI Hide name button?

Asked by 8 years ago
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.

0
This had an answer.. then.. it disappeared. Maxwell_Edison 105 — 8y

2 answers

Log in to vote
2
Answered by
Exudo 13
8 years ago

NameDisplayDistance and HealthDisplayDistance are apart of Player

So change Character.Humanoid to player.

Ad
Log in to vote
0
Answered by
woodengop 1134 Moderation Voter
8 years ago

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.

Answer this question