Hi, I’m trying to change an attribute of a sword tool, and I’m trying to change it to the Effect Attribute of it’s player’s HumanoidRootPart. Here is my code:
-- local script
local event = game:GetService("ReplicatedStorage").AddEnchantments
local players = game:GetService("Players")
local plr = players.LocalPlayer
event.OnClientEvent:Connect(function(_, str, spd, uses)
print("Event fired!")
local char = plr.Character
local root = char:FindFirstChild("HumanoidRootPart")
local effect = root:GetAttribute("Effect")
local sword = char:FindFirstChild("Sword")
print(effect)
if effect == "Hard-Hitting" then
sword:SetAttribute("Effect", effect)
root:SetAttribute("Effect", nil)
elseif effect == "Sturdy" then
sword:SetAttribute("Effect", effect)
root:SetAttribute("Effect", nil)
elseif effect == "Speedy" then
sword:SetAttribute("Effect", effect)
root:SetAttribute("Effect", nil)
end
end)
As you can see, the output displays an error saying that I can’t set an attribute for the Sword, even though it has attributes. I don’t know why this happens. I tried many different ways with a normal Script, but then it didn’t work at all. Any ideas why this is happening?