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

How do you access something by a ClassName?

I want to be able to delete hats locally. I have been told something about "Super Classes", but I just want to delete hats. May I have any help?

Sorry, what I specifically want to do is remove a player's hats when they click a GUI. I have the function already set, but how would I incorporate the LocalPlayer's hats being removed?

1 comment

0

("IsA()") will check the class of the specific object.

3 answers

✓ Accepted answer
Hats = Workspace:GetChildren()

function RemoveHats()
for i,v in pairs (Hats) do
if v.ClassName == "Hat" then
v:remove()
end
end



while wait(3) do
RemoveHats()
end
--This script would remove all the Hats in Workspace each 3 seconds , at least that's what it should do.

Hope it helps.

1 comment

0

Well, how would I do it to a LocalPlayer, when they click a GUI?

You can use the IsA method. Here's an example.

if workspace.Part:IsA("Hat") then
	workspace.Part:Destroy()
end

And it'll check for the class of the part in Workspace

Well just find and define the location of the hats say for local hat = game.Workspace.putnamehere and then just hat:Remove()

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