Name Issue Problem

  1. What do you want to achieve? Im making a system where if you click the player it gives you their info (name, account age, Role In Group, etc). Im having trouble with the name… sad, right? Im trying tons of different things but it doesn’t seem to be working.

  2. What is the issue? It won’t work.

  3. What solutions have you tried so far? YouTube videos.

This is my script

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

local tool = script.Parent

local Frame = game.Players.LocalPlayer.PlayerGui:WaitForChild('ScreenGui'):WaitForChild('Frame') --Object path to the GUI frame containing the age and rank textboxes.
local groupID = 4796549 --ID of your group.

tool.Activated:Connect(function()
	for _,Target in pairs(game.Players:GetPlayers()) do
		if Mouse.Target:IsDescendantOf(Target.Character) then
			Frame.Visible = true
			Frame.AccAge.Text = Target.AccountAge
			Frame.RoleInGroup.Text = Target:GetRoleInGroup(groupID)
			Frame.Name.Text = Target.Name
			
			wait(3)
			
			Frame.Visible = false
		end
	end
end)




-- Make sure they can't use the tool while it is not selected.
tool.Unequipped:Connect(function()
	Frame.Visible = false
end)

This is the error that pops-up.

The error just means that there is no property or child of ImageLabel called Text. Make sure you are locating the right UI objects.

Looks like you should be using a TextLabel here. An ImageLabel won’t display any text.

1 Like

poof
But there is…

That’s the issue. The TextLabel named Name is causing an issue with the script to attempt to index the .Name property of the ImageLabel.

Name the TextLabel something else, and avoid naming children anything similar to properties.

Change the name of TextLabel to something different than Name or you can use :FindFirstChild("Name") and it should work.

Frame:FindFirstChild("Name").Text = Target.Name

Still doesn’t work. Thanks though.

I’m pretty sure FindFirstChild whould work, but use this code to test a custom FindFirstChild:

local function FindFirstChild(Obj,Name)
      local ReturnObj
      for _,Object in ipairs(Obj:GetChildren()) do
             if Object.Name == Name then
                    ReturnObj = Object
             end
      end
      return ReturnObj
end
FindFirstChild(Frame,"Name").Text = Target.Name

You should just generally avoid naming children after properties. They’re bound to error, and FindFirstChild is a bit of a hacky fix for it. Naming the label something like DisplayName would suffice.

Also square brackets are good idea, try this:

Frame["Name"].Text = Target.Name

Edit: replied to wrong person.


Not a fix either…

I’ll give my last try and that’s :FindFirstAncestor() funciton, example:

Frame:FindFirstAncestor("Name").Text = Target.Name

You can’t set Enabled, you can only set every object in that GUI’s visible to false.

Edit: @ArticGamerTV The problem is that he is trying to set the Enabled propriety which is not possible.

I know the easy way is to change the name but I tried that and even that doesn’t work. I think it doesn’t know what to change it to.

May I ask you to try my last try, the ancestor function I sent above?

Yes, I am doing so right now…

ScreenGuis have a property called Enabled which can be assigned to. Try it in Studio.

Why do I need to make it enabled?

You can’t assign the Enabled propiety using scripts. Please see the context of this topic. Oh… I forgot roblox isn’t the same like in 2017…

You don’t, that was just an example as to why you should not name children after properties. Errors like that happen.

@TheTurtleMaster_2 LayerCollector | Documentation - Roblox Creator Hub

It’s a simple solution to just change the name of the label.