Attempt to index nil with 'name' When changing the value of Text Label

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to change the text value of a text label depending on the variable parsed through a remote.
  2. What is the issue? Include screenshots / videos if possible!
    attempt to index nil with ‘name’ when “Done!” button is pressed. I am not sure if the http get request will work, but I am sure that the server is working.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried many dev forum posts but to no avail.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("Username")

local function onLogIn(player, TikTokAT)
	if not player.Character then
		return
	end
	print(TikTokAT)
	local newClone = game.ReplicatedStorage.UsernameGUI:Clone()
	newClone.Parent.name.text = (TikTokAT)
	local HttpService = game:GetService("HttpService")

	local ACCOUNT = "http://[IP]:8000/"+(TikTokAT)

	-- Make the request to our endpoint URL
	local response = HttpService:GetAsync(ACCOUNT)

	newClone.Parent.followers.text = (response)
	newClone.Parent = player.Character.Head
end
-- Call "onCreatePart()" when the client fires the remote event
remoteEvent.OnServerEvent:Connect(onLogIn)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

When you clone an Instance, its parent is set to nil.

1 Like

Im sorry, Im new to LUA. But aren’t I resetting the value to what its supposed to be at line 11?

What are you trying to do with this?

Im trying to set the text of a text label that will be above the player’s head to their socials.

Locate the clone right after the variable.

local newClone = game.ReplicatedStorage.UsernameGUI:Clone()
newClone.Parent = player.Character.Head

--and so on

Don’t forget to capitalize the first letter of text.

newClone.Parent.name.Text = TikTokAT -- Assuming this is a string

Set the Instance's Parent before using it.

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("Username")

local function onLogIn(player, TikTokAT)
	if not player.Character then
		return
	end
	print(TikTokAT)
	local newClone = game.ReplicatedStorage.UsernameGUI:Clone()
	newClone.Parent = player.Character.Head
	newClone.Parent.name.text = (TikTokAT)
	local HttpService = game:GetService("HttpService")

	local ACCOUNT = "http://[IP]:8000/"+(TikTokAT)

	-- Make the request to our endpoint URL
	local response = HttpService:GetAsync(ACCOUNT)

	newClone.Parent.followers.text = (response)
end
-- Call "onCreatePart()" when the client fires the remote event
remoteEvent.OnServerEvent:Connect(onLogIn)

Let me know if this works

1 Like

This did fix the error, but it brought up an “attempt to index string with ‘text’” error

Capitalize the first letter. Because you are trying to change the property of the text label.

I have, all it did was change from “attempt to index string with ‘text’” to “attempt to index string with ‘Text’”

Weird, do you have something called “name” in your Explorer? Check it out.

Yeah, I do. “name” is the name of the Text Label.

newClone variable refers to the screen GUI, am I correct?

If it is possible, can you please post your screenshot for a better inspection?

image
I hope that helps

:man_facepalming: Delete parent here. Because its parent is ReplicatedStorage.

1 Like

Thank you, I don’t have a very keen eye for that sort of stuff.

1 Like