I have a question about this script, I’m trying to equip an accessory to a character when a tool is activated. Then I want to remove the accessory and reduce the player’s health when the tool is activated again. I’m not sure why, but the warning that says “AduriteCrownAccessory not found in ServerStorage” keeps happening in the output. I have the crown in server storage and I have the name as AduriteCrownAccessory. Can someone explain to me whats going on? This is the script
local Tool = script.Parent
local equipped = false
local function equipAccessory()
local character = Tool.Parent
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
local AduriteCrownAccessory = game.ServerStorage:FindFirstChild("AduriteCrownAccessory")
if AduriteCrownAccessory then
local clone = AduriteCrownAccessory:Clone()
clone.Parent = character
humanoid.Health = humanoid.Health + 30
print("Equipped Adurite Crown and added 30 HP.")
else
warn("AduriteCrownAccessory not found in ServerStorage.")
end
end
end
local function unequipAccessory()
local character = Tool.Parent
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
local accessory = character:FindFirstChild("AduriteCrownAccessory")
if accessory then
accessory:Destroy()
humanoid.Health = humanoid.Health - 30
print("Unequipped Adurite Crown and removed 30 HP.")
end
end
end
Tool.Activated:Connect(function()
if equipped then
unequipAccessory()
else
equipAccessory()
end
equipped = not equipped
end)