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

this question involves detecting if the player is wearing something?

Asked by 7 years ago

if the player is wearing this hat then it will not deduct health, otherwise it will.

1 answer

Log in to vote
0
Answered by
Is_Hunter 152
6 years ago

I didn't know what you are really trying to make but here is a example on how to detect something

-- this script is in a Part
-- SCRIPT
local Hat = "Fedora"
loca Part = script.Parent

local function onTouched(Hit)
    local Character = Hit.Parent
    if Character ~= nil then
        local Humanoid = Character:FindFirstChildOfClass("Humanoid")
        if Humanoid ~= nil and Humanoid.Health > 0 then
            for _, Child in ipairs(Character:GetChildren()) do
                if Child.Name == Hat then
                    -- Does what every you want
                end
            end
        end
    end
end

Part.Touched:connect(onTouched)
Ad

Answer this question