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

Name-Changing LocalScript won't work?

My LocalScript is supposed to change a player's name upon clicking a textbutton, but it doesn't do anything and has no output errors.

Let's say the player's username is BobtheRandomUsername12345. The script is supposed to change his displayed name to BobtheRandomUsername12345: Testing if he clicks the button.

script.Parent.MouseButton1Click:connect(function(enter)
	if enter then
		v = game.Players.LocalPlayer
		for a, mod in pairs(v.Character:children()) do
			if mod:findFirstChild("NameTag") then
				v.Character.Head.Transparency = 0 mod:Destroy()
			end
		end

		local char = v.Character
		local nam = (v.Name .." : Testing")
		local mod = Instance.new("Model", char)
		mod.Name = nam
		local cl = char.Head:Clone()
		cl.Parent = mod

		local hum = Instance.new("Humanoid", mod)
		hum.Name = "NameTag"
		hum.MaxHealth = 0
		hum.Health = 0

		local weld = Instance.new("Weld", cl) weld.Part0 = cl weld.Part1 = char.Head
		char.Head.Transparency = 1
	end
end)

Does know why this doesn't work and can tell me how to fix it? Thanks!

1 answer

✓ Accepted answer

MouseButton1Click does not have any built-in parameters.

Therefore, enter will always be nil, and the if statement will never pass. I'm not sure what you thought it would do, so I can't offer much of a solution.

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