I have the rest of the script but is "Hat" even a thing to put in here? Hard to explain
if v:IsA("Hat") then
v:remove()
end
I have the rest of the script but is "Hat" even a thing to put in here? Hard to explain
if v:IsA("Hat") then
v:remove()
end
The IsA method is used to test what Class the ROBLOX Object you have a reference to.. Is.
Hat is a ROBLOX Class. As are Part, Script, Mesh, and some more technical ones such as RemoteEvent.
All ROBLOX Classes have the IsA method because Lua does not directly support Classes, unlike C/C++ which ROBLOX is actually written in. IsA checks the ClassName of the Object the method is used on, as well as all ClassNames of the given object's inherited classes.
To explain that last part, Trusses, WedgeParts, MeshParts, VehicleSeats, and, not to forget, Parts, all inherit from the BasePart abstract class. What 'abstract class' means is out of the scope of this answer.
Instance.new("Part"):IsA("BasePart") --> true
Instance.new("WedgePart"):IsA("BasePart") --> true
Instance.new("WedgePart"):IsA("Part") --> false
Instance.new("Model"):IsA("BasePart") --> false
Instance.new("VehicleSeat"):IsA("VehicleSeat") --> true
Instance.new("TrussPart"):IsA("BasePart") --> true
I hope this answers any questions you had about the IsA method.
So what would take place of "Hat"?
I don't understand the question.
This discussion is preserved as it was. New answers, comments, and votes are closed.
5 comments
Yes.
Hat is a Class, any classname will fit into :IsA().
So would " if v.ClassName("Hat") then v:remove() end" be better
IsA would be better because it's simpler and slightly more efficient.
IsA is neither simpler nor more efficient. It does however, check the inherited classes' ClassNames in addition to the ClassName of the passed object.