Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How do you access something by a ClassName?

Asked by 8 years ago
Edited 8 years ago

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?

0
("IsA()") will check the class of the specific object. PreciseLogic 271 — 8y

3 answers

Log in to vote
0
Answered by 8 years ago
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.

0
Well, how would I do it to a LocalPlayer, when they click a GUI? MEANDUDE87 60 — 8y
Ad
Log in to vote
0
Answered by
itsJooJoo 195
8 years ago

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

Log in to vote
-2
Answered by 8 years ago

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

Answer this question