Hello, i got a script on my roblox studio that is not working, could someone tell me whats wrong with it?
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local sword = nil
for i,v in pairs(character:GetChildren()) do
if v:IsA("Tool") and v.Name == "Sword" then
sword = v
break
end
end
if sword then
game:GetService("UserInputService").InputBegan:Connect(function(input, processed)
if input.UserInputType == Enum.UserInputType.MouseButton1 and input.KeyCode == Enum.KeyCode.RightButton and not processed then
humanoid:UnequipTools()
sword.Parent = character
humanoid:EquipTool(sword)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Attacking, true)
end
end)
end