LocalScript in StarterCharacterScripts refuses to identify accessories, why

Is it not possible for a LocalScript in StarterCharacterScripts to find an accessory within the local player? It needs to be a LocalScript in StarterCharacterScripts otherwise the rest of my code won’t work and I’m not going to resort to inserting a RemoteEvent and another script in ServerScriptService. What’s going on here???


1 Like

Most likely due to the fact the script runs before character accessories are loaded. Add a task.wait(3) or something like that before the if Char[“Pal Hair”] check. If it works after that change, that’s the issue.

I would suggest using CharacterAppearanceLoaded, but that doesn’t seem to work in LocalScripts. For context this works fine for me, although I wouldn’t recommend adding task.wait in live production.

--starter character script
local Character = script.Parent
task.wait(3)

if Character["Fedora"] then
	print("lol")
end

Wow, I can’t believe that one line actually fixed my script. You are a lifesaver man!

1 Like

This is a terrible solution because it can take the character to load longer; instead use

script.Parent.ChildAdded:Connect(function(child)
if child.Name == "Fedora" then
print("big chungus")
end
end)
1 Like

I never implied it was a solution?? It was simply a stepping stone to diagnose the issue on his side.

Either way, if you actually using this in production I’d recommend this, it has more stability.

1 Like

Oh yeah I didn’t read your full post, apologies. Also, modified code a bit

local fedora = script.Parent.Fedor
script.Parent.ChildAdded:Connect(function(child)
if child.Name == "Fedora" and not fedora ~= nil then
print("big chungus")
end
end)
2 Likes