Script won't detect accessories on the player!

How would I go about making this script detect if the local player is wearing Pal Hair? I can’t seem to get it to work in the same manner like detecting the Headless Head mesh. Insert a Local Script into StarterCharacterScripts and paste in the code below to see if you can find the problem.

  • local plr = game.Players.LocalPlayer
    local Char = plr.Character
    local Humanoid = Char.Humanoid
    if Char:FindFirstChild(“Pal Hair”).Handle.MeshId == “rbxassetid://83293901” then
    Humanoid.WalkSpeed = 24

    bc = BrickColor.new(“Lime green”)
    game.StarterGui:SetCore(“ChatMakeSystemMessage”, {
    Text = “You have been detected for wearing Pal Hair.”;
    Font = Enum.Font.Legacy;
    Color = bc.Color;
    FontSize = Enum.FontSize.Size10;
    })
    bc = BrickColor.new(“New Yeller”)
    game.StarterGui:SetCore(“ChatMakeSystemMessage”, {
    Text = “+8 WalkSpeed”;
    Font = Enum.Font.Legacy;
    Color = bc.Color;
    FontSize = Enum.FontSize.Size10;
    })
    end

You can simply check if the player has an object called ‘Pal Hair’ and check if that object is an accessory aswell.

for _,child in pairs(Char:GetChildren()) do
	if string.match(child.Name,"Pal Hair") and child:IsA("Accessory") then
		--code
	end
end

A working example :


for _,child in pairs(Char:GetChildren()) do
	if string.match(child.Name,"Buns") and child:IsA("Accessory") then
		print(child.Name) --Braided Buns 2
	end
end

Could you insert that into my script together?

Could you please send a formatted script? [as I did], it’d help

I’ll send you a model of the script to insert in studio

1 Like

(5) PalHairDetector - Roblox

local plr = game.Players.LocalPlayer
local Char = plr.Character
local Humanoid = Char.Humanoid
if Char:FindFirstChild(“Pal Hair”).Handle.MeshId == “rbxassetid://83293901” then
Humanoid.WalkSpeed = 24

bc = BrickColor.new("Lime green")
game.StarterGui:SetCore("ChatMakeSystemMessage", {
	Text = "You have been detected for wearing Pal Hair.";
	Font = Enum.Font.Legacy;
	Color = bc.Color;
	FontSize =	Enum.FontSize.Size10;
})
bc = BrickColor.new("New Yeller")
game.StarterGui:SetCore("ChatMakeSystemMessage", {
	Text = "+8 WalkSpeed";
	Font = Enum.Font.Legacy;
	Color = bc.Color;
	FontSize =	Enum.FontSize.Size10;
})
end
--SERVER SCRIPT[serviceScriptService]
local client = game.ReplicatedStorage.Client

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Char)
		task.wait(1)
		for _,child in pairs(Char:GetChildren()) do
			if string.match(child.Name,"Pal Hair") and child:IsA("Accessory") then
				Char.Humanoid.WalkSpeed = 24
				client:FireClient(Player,"You have been detected for wearing a Pal Hair!")
				task.wait(3)
				client:FireClient(Player,"Enjoy your +8 extra WalkSpeed!")

			end
		end
	end)
end)

--Client[StarterPlayerScripts]
local rs= game:GetService("ReplicatedStorage")
local event = rs:WaitForChild("Client")

event.OnClientEvent:Connect(function(msg)
	game.StarterGui:SetCore("ChatMakeSystemMessage",{
		Text = msg;
		Font = Enum.Font.Legacy;
	})
end)


image

Yours works, but try this and insert it into StarterCharacterScripts.

(5) Headless Reward with message - Roblox

That one works and it’s only 1 script, is the same not possible when it comes to accessories?