IsClass

Constructor:

IsClass(ClassName)

Description

Judges whether the object class is the same or not. If you want to change some of the Parts in the Model, it is recommended to use GetAllChild to retrieve all the children in the Model, then select the parts by class via IsClass and change them in groups.

Parameters

Variable name Type Default Description
ClassName string Class name of object specified to creat

Return Value

Type Description
bool The judgment result returned, True or False

Examples

When the player touches a part, generate a part to hit the player.

local temp = script.Parent -- define the parent of the script as temp
function creat() -- define the method creat
    temp1 = RWObject.Create("Part") -- create an instance object of Part
    temp1.Position  = temp.Position + Vector3.New(0,10,0) -- define the position of temp1
    temp1.CollisionEnter:Connect(attack) -- when the temp1 object is hit, connect the method attack
end
function attack(res1) -- define the method attack, and input the parameter res1
    if res1:IsClass("Avatar") then -- judge whether the parameter class is Avatar        
            res1.Health = 0    -- the player's HP value is 0
    end 
end
temp.CollisionEnter:Connect(creat) -- when temp is hit, connect the method creat