script.Parent:WaitForChild("Handle");

local gearConfig = {
	gear = script.Parent,
	equipped = false,
	isSwinging = false,
	attackDeb = true,
	check = true,
	debris = game:GetService("Debris"),
	anims = {
		script.Parent:WaitForChild("Slash2Anim"),
		script.Parent:WaitForChild("Slash3Anim"),
		script.Parent:WaitForChild("Slash4Anim"),
	},
	sounds = {
		script.Parent.Handle:WaitForChild("Slash1")
	},
	readyAnims = {},
	deb = 0.75,
	damage = 50
};

script.Parent.Handle.Touched:connect(function(hit)
	if hit.Parent~=game.Players.LocalPlayer.Character and hit.Name~="Handle" and hit.Name~="Effect" and gearConfig.isSwinging and gearConfig.attackDeb then
		local h=hit.Parent:FindFirstChild("Humanoid");
		local t=hit.Parent:FindFirstChild("Torso");
		if h~=nil and t~=nil and h.Health>0 then
			gearConfig.attackDeb = false;
			for i,v in ipairs(h:GetChildren()) do
				if v.Name=="creator" then
					v:remove();
				end
			end
			local c = Instance.new("ObjectValue", h);
			c.Name = "creator";
			c.Value = game.Players.LocalPlayer;
			h:TakeDamage(gearConfig.damage);
			wait(0.05);
			gearConfig.attackDeb = true;
		end
	end
end);

gearConfig.gear.Unequipped:connect(function()
	gearConfig.equipped = false;
end);

gearConfig.gear.Equipped:connect(function(m)
	gearConfig.equipped = true;
	if (m ~= nil) then
		local human=script.Parent.Parent:findFirstChild("Humanoid");
		for i=1, #gearConfig.anims do
			table.insert(gearConfig.readyAnims, human:LoadAnimation(gearConfig.anims[i]));		
		end
		
		m.Button1Down:connect(function()
			if (gearConfig.check and human.Health > 0) then
				gearConfig.check = false;
				local a = math.random(1, #gearConfig.readyAnims);
				gearConfig.readyAnims[a]:Play();
				gearConfig.sounds[math.random(1, #gearConfig.sounds)]:Play();
				gearConfig.isSwinging = true;
				Spawn(function() wait(gearConfig.deb); gearConfig.check = true; end);
				repeat gearConfig.trail(); wait(0.085) until gearConfig.check or not gearConfig.equipped		
				gearConfig.isSwinging = false;	
			end
		end);
		
		m.Button1Up:connect(function()
			if (gearConfig.check and human.Health > 0) then
				
			end
		end);
	end
end);

Error: Players.Player.Backpack.Fire Tribe.LocalScript:67: attempt to call field 'trail' (a nil value)

2 comments

0

Could you give us where you define trail?

0

I added in the table so you can see.