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

Problem With My Hide Name GUI, Please help?

The transparencies are working fine, it's just that whenever I click the button it will kill me (at least right now I know how to make a reset button). Can anyone find my problem?

local nameshowing=true
local fakehead=script.Parent.Parent.Parent.Parent.Character.Head:Clone()
local plr=script.Parent.Parent.Parent.Parent
script.Parent.MouseButton1Click:connect(function()
local shouldhidename = true
if nameshowing == true then
shouldhidename = true
else shouldhidename=false
end
if shouldhidename==true then
	if plr.Character ~=nil then
	if plr.Character:FindFirstChild("Head") then
		plr.Character.Head.Transparency=1
		fakehead.Parent=plr.Character
		fakehead.Name = "FakeHead"
		fakehead.CFrame=plr.Character.Head.CFrame
		w=Instance.new("Weld",plr.Character.Head)
		w.Part0 = plr.Character.Head
		w.Part1 = fakehead
		nameshowing = false
	end
	end
else
	fakehead.Transparency = 1
	plr.Character.Head.Transparency = 0
	nameshowing=true
end
end)

Any help will be appreciated, thanks for your time.

3 answers

Why did you make a script inside another thing? You need to create a LocalScript in some storage service, then clone it in the playergui and execute the function in your mouse script, kinda like this:

_G.hideBillboard = function()
	local player = game.Players.LocalPlayer
	local fakeHead = player.Character.Head:Clone().Parent(player.Character)
	fakeHead.Name = "FakeHead"
	player.Character.Head.Transparency = 1
	player.Character:WaitForChild("FakeHead") -- Wait for the FakeHead to be loaded
	local weld = Instance.new("Weld") 
	weld.Parent = player.Character.Head
	weld.Part0 = player.Character.Head
	weld.Part1 = player.Character.FakeHead
end

_G.unhideBillboard = function()
	-- Opposite of hideBillBoard()
end

After you can call those method outside everything:

function onMouseClick()
	-- I suppose that you have a boolean called "hidden" that checks if the game needs to hide/unhide the billboard
	if hidden then 
		_G.unhideBillboard()
	else
		_G.hideBillboard()
end

4 comments

0

The script is inside the button inside a screengui, inside the startergui, which is inside the player so there are four parents. I think my problem here is the welds. But does it need to be inside a localscript in order for it to work?

0

I edited the message

0

Just moved my code to a LocalScript, thank you.

0

No problem ;)

Would it have been possible to rename your humanoid to nothing so the name doesn't show up? Just wondering.

2 comments

0

No, it is not possible. Since your character is connected to your player I guess that makes your character's name ROBLOX locked, since I've tried changing it in two ways in studio one being script and the other being through properties with no change.

0

Ok thanks! Mind checking my most recent question?

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