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

Where do I get the precise name of a hat in roblox studio?

It's sort of hard to explain. What I mean is, if I want to detect if someone's wearing a hat when they enter a game, the script will know it's that hat. I have the script done, but each time I want to know the name of the hat, I have to keep entering the game, checking what the player is wearing and then copy letter by letter. For example:

local hat = hit.Parent:FindFirstChild("SnipersVisor")

If I put Snipers Visor, it wouldn't work. And I wouldn't know that it would be together. So does anyone know where I could get the name?

1 comment

0

You can check the class name or use IsA.

1 answer

Here this should work.

-- ServerScript.

local PLAYERS = game:GetService("Players")

PLAYERS.PlayerAdded:connect(function(Plr)
	Plr.CharacterAppearanceLoaded:connect(function(Char)
		for i, v in pairs(Char:GetChildren()) do
			if v:IsA("Hat") then
				-- Do whatever you want here.
			end
		end)
	end)
end)

1 comment

0

Roblox is currently adding a new Instance:FindFirstChildOfClass(class) method; It should be around soon. No more looping through all the children to find a single hat!

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