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

How to Check if player is wearing a certain accessory?

Asked by 6 years ago
Edited 6 years ago

I want to change "damage" if player is wearing an accessory. No idea how to check if player is wearing accessory but tried this.

local Player = game.Players.LocalPlayer
repeat wait() until Player.Character~= nil
local Char = Player.Character

if Char:FindFirstChild("MagicTopHat")~= nil then
    damage = damage * 50
end

This is a localscript inserted into starterpack.

Any help would be appreciated. Thanks :D

0
if Char:FindFirstChild("MagicTopHat")~= nil then 6 damage = damage * 50 7 end try using if Char.MagicTopHat then damage = damage * 50 end LastApollo 76 — 6y
0
Sorry, i don't know how to use markup text for the code LastApollo 76 — 6y
0
null * 50 ? , I think not . User#17685 0 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago

Every accesory have a unique mesh and the mesh has a unique ID. You can check if the mesh is using a certain ID and that's how you figure out what accessory it is. You can also do this for shirts, pants, and T-shirts.

Char = game:GetService("Players").LocalPlayer
damage = 10

if Char:FindFirstChild("MagicTopHat") then
    if Char.MagicTopHat:FindFirstChild("Handle") then
        if Char.MagicTopHat.Handle:FindFirstChild("Mesh") then
            if Char.MagicTopHat.Handle.MeshId == "" then -- insert mesh Id here
                damage = damage * 50
            end
        end
    end
end

I went to make sure that it could find the accessory's handle and mesh in case it was renamed or so. The default name for a Accessory's part is always Handle.

0
Hehe give me a little bit to check if this works. Roblox Studio Pulled a didn't save so now I have to restart the script from scratch :D NickDestroyer123 12 — 6y
0
Didn't work. Found Another way to change damage. Im accept anyways NickDestroyer123 12 — 6y
0
I meant accessory. User#18043 95 — 6y
Ad

Answer this question