"attempt to index nil with "PlayerStats"

one thing id like to say is ive gotten so many of those “attempt to index nil with” garbage errors yesterday, but a wait(5) usually seemed to fix it. you dont have to, its just a suggestion

2 Likes

This script is the only mention of server storage

Screen Shot 2023-08-29 at 5.23.44 PM

2 Likes

the problem here isn’t that the game hasn’t been loaded yet. As previously seen on the screenshot, the BillboardGui dissapears whenever he joins the game so there must be something going on with the scripts.

2 Likes

oh my bad sorry
eeeeeeeeeeeeee

2 Likes

Instead of putting it inside of the ServerStorage, maybe put it directly into the “NameTagScript”.
change the line with the following:

local nameTag = script:WaitForChild("PlayerStats")
2 Likes
local nameTag = game:GetService("ServerStorage"):WaitForChild("PlayerStats")

game.Players.PlayerAdded:Connect(function(plr)
	repeat task.wait() until plr.CharacterAdded
	workspace:WaitForChild(plr.Name).Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
	
	local nameTagClone = nameTag:Clone()
	nameTagClone.Frame.Name.Text = plr.Name
	nameTagClone.Parent = workspace[plr.Name].Head
end)

entire script

2 Likes

Tried that and it didn’t work.

2 Likes

I mean you can try shifting the code around i guess

game.Players.PlayerAdded:Connect(function(plr)
	repeat task.wait() until plr.CharacterAdded
	workspace:WaitForChild(plr.Name).Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
	
	local nameTagClone = game:GetService("ServerStorage"):WaitForChild("PlayerStats"):Clone()
	nameTagClone.Frame.Name.Text = plr.Name
	nameTagClone.Parent = workspace[plr.Name].Head
end)
2 Likes
game.Players.PlayerAdded:Connect(function(plr)
	repeat task.wait() until plr.CharacterAdded
	workspace:WaitForChild(plr.Name).Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
	
	local nameTagClone = game:GetService("ServerStorage"):WaitForChild("PlayerStats"):Clone()
	nameTagClone.Frame.Name.Text = plr.Name
	nameTagClone.Parent = workspace[plr.Name].Head
end)
2 Likes

That was actually my first iteration of the code and that wasn’t working so I switched it around

1 Like

that was a funny coincidence lol

2 Likes

indeed lol lllllllllllllllllllllllllll

2 Likes

do the search method i showed you before and look for scripts that use :Destroy or :Remove

2 Likes

I just tested in my own studio with no errors, something is clearly changing the UI.

1 Like

No scripts are using those functions

1 Like

try making a backup and naming it backupnametag or something

1 Like

You sure you turned on archivable?

It should be turned on for the UI Object
I got an error only when i turned it off.

1 Like

also this doesn’t seem correct. This is better;

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		char.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
	
		local nameTagClone = game:GetService("ServerStorage"):WaitForChild("PlayerStats"):Clone()
		nameTagClone.Frame.Name.Text = plr.Name
		nameTagClone.Parent = char:WaitForChild("Head")
	end)
end)
1 Like

I had no idea archivable had to be on.

I also didn’t know what it does

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.