Attempt to Index nil with 'Blade'

I’ve been making a sword script, but I keep getting an error that keeps showing up.
Script:

local Character = player.CharacterAdded:Wait()
local mouse = player:GetMouse()
local debounce = false
local sword = Character:WaitForChild("Sword", 1)
local RaycastHitbox = require(workspace.RaycastHitboxV3)
local Damage = 20
wait(2)
local blade = sword.Blade
local Hitbox = RaycastHitbox:Initialize(blade, {Character})
local replicatedStorage = game.ReplicatedStorage
local particlepart = replicatedStorage["Particle Part"]


mouse.KeyDown:Connect(function(key)
	if key == "f" then
		if not debounce then
			debounce = true
			
			local humanoid = Character.Humanoid
			local Animations = Character.Animations
			local animatior = humanoid.Animator
			local Animation = animatior:LoadAnimation(Animations.swip)
			
			
			Hitbox:HitStart()
			Animation:Play()
			blade.Swipe:Play()
			wait(.5)
			Animation:Stop()
			Hitbox:HitStop()
			debounce = false
		end
	end
end)

Hitbox.OnHit:Connect(function(hit)
	print(hit.Name)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	local particle = particlepart.Spark:Clone()
	particle.Parent = hit
	
	humanoid:TakeDamage(Damage)
	blade.Hit:Play()
	particle.ParticleEmitter:Emit(10)
	wait(1)
	particle:Destroy()
end)

game:GetService("RunService").RenderStepped:Connect(function()
	local character = game.Players.LocalPlayer.Character
	repeat wait() until character:FindFirstChild("Sword")
	local sword = character:FindFirstChild("Sword")
	for _, part in ipairs(character:GetDescendants()) do
		if part:IsA("MeshPart") then
			-- Remember that LTM is a multiplier; 0-values will not force different transparency
			if debounce then
				part.LocalTransparencyModifier = 0
				blade.Trail.Enabled = true
				blade.Blue.Enabled = true
			else
				part.LocalTransparencyModifier = 1
				blade.Blue.Enabled = false
				blade.Trail.Enabled = false
			end
		end
	end
end) 

Error: [16:05:38.017 - Players.DullXxxswagfoxyxxX.PlayerScripts.Sword:10: attempt to index nil with 'Blade']

1 Like

Maybe check capitalization or spelling issues.

Oh yeah can you also show the parts inside the sword? Screenshot

You should try using :Init() instead of Intialize

image
I don’t see any capitalization errors here.

The module doesn’t have the function :Init()

is the sword given to the player located in starterplayertool

The sword is not a tool. It is an accessory.

Have you checked if the module script even exists or you mispelled it

where are they originally located, sword and blade

My problem has nothing to do with the module script.

ServerStorage, and then put into the character.

The cloning is done in another script

hmmmmm I’m wondering if it clones the sword’s child at the same time.

The blade is the child of the sword. And I clone the accessory, which would clone all of its children

is Archivable on for all of them

It is, everything clones to the character, the sword script just cant FIND it.
image

try to put another waitforchild for blade .-. I think

I have tried that, it hasn’t worked.

Try taking out the “1” for the timeOut argument on sword = Character:WaitForChild(“Sword”, 1)

It probably isn’t waiting long enough to find it before it loads.

So you’re saying I should increase the timeOut?