so heres the basics, im making a weapon. wont work. help.
the script was from https://www.youtube.com/watch?v=hWvqqBZUPco
script:
--This is the main script of the weapon. scroll down for the stuff you edit.
local tool = script.Parent.Parent
local player = nil
local character = nil
local humanoid = nil
local blade = tool:WaitForChild("Blade")
local animation = tool:WaitForChild("Animation")
local equipped = false
local canDetect = false
local comboAnim = animation:WaitForChild("Combo")
local equipAnim = animation:WaitForChild("Equip")
local holdAnim = animation:WaitForChild("Hold")
local slashAnim = animation:WaitForChild("Slash")
local slash2Anim = animation:WaitForChild("Slash2")
local comboTrack = nil
local equipTrack = nil
local holdTrack = nil
local slashTrack = nil
local slash2Track = nil
local equipSound = blade:WaitForChild("EquipSound")
local hitSound = blade:WaitForChild("HitSound")
local slashSound = blade:WaitForChild("SlashSound")
------------------------------------------------------------------------------------------
-- the config zone
local Damage = 10
local CoolDown = 0.3
local Combo = 1
local LastSwing = tick()
local CanDamageNPCs = true
local CanDamagePlayers = true
------------------------------------------------------------------------------------------
--more sword stuff
local function damage(hum, isPlayer) --damage stuff
--chacking some damage stuff
if (isPlayer and CanDamagePlayers) or (not isPlayer and CanDamageNPCs) then
--some damage stuff
local newDamage = Combo * Damage
--deal damage
hum:TakeDamage(newDamage)
hitSound:Play()
end
end
local function swing()
local checkSwing = math.abs(tick() - LastSwing)
--checking swing stuff
if (checkSwing > CoolDown) and equipped then
if checkSwing - CoolDown < 0.2 and Combo < 3 then
Combo = Combo + 1
else
Combo = 1
end
LastSwing = tick()
canDetect = true
local humsDetected = {}
local success = pcall(function()
slashSound:Play()
--combo checking
if Combo == 1 then
--basic attack
slashTrack:Play()
slashTrack.Stopped:Connect(function()
canDetect = false
end)
elseif Combo == 2 then
--stronger attack
slash2Track:Play()
slash2Track.Stopped:Connect(function()
canDetect = false
end)
elseif Combo ==3 then
--srongest attack
comboTrack:Play()
comboTrack.Stopped:Connect(function()
canDetect = false
end)
end
end)
--hit detetction
blade.Touched:Connect(function(partHit)
if not canDetect then return end
canDetect = false
local isPlayer = game:GetService("Players"):GetPlayerFromCharacter(partHit.Parent)
local hum = partHit.Parent:FindFirstChild("Humanoid")
for i, v in pairs(humsDetected) do
if v ==hum.Parent.Name then
return
end
end
--update player hit
if #humsDetected < 1 then
table.insert(humsDetected, hum.Parent.Name)
damage(hum, isPlayer)
end
end)
canDetect = success
end
end
local function equip()
--Initialize
player = game:GetService("Players"):GetPlayerFromCharacter(tool.Parent)
character = player.Character or player.CharacterAdded:Wait()
humanoid = character:WaitForChild("Humanoid")
--play animation
pcall(function()
holdTrack = humanoid:LoadAnimation("holdAnim")
end)
local succsess = pcall(function()
equipTrack = humanoid:LoadAnimation(equipAnim)
equipSound:Play()
equipTrack.KeyframeReached:Connect(function(keyframeName)
if keyframeName == "Pull" then
equipSound:Play()
end
end)
equipTrack.Stopped:Connect(function()
if tool.Parent.ClassName ~= "Model" then return end
holdTrack:Play()
end)
end)
pcall(function()
slashTrack = humanoid:LoadAnimation(slashAnim)
end)
pcall(function()
slash2Track = humanoid:LoadAnimation(slash2Anim)
end)
pcall(function()
comboTrack = humanoid:LoadAnimation(comboAnim)
end)
equipped = not succsess
end
local function dequip()
equipped = false
--stop playing sounds
slashSound:Stop()
equipSound:Stop()
--stop playing animations
if holdTrack then
holdTrack:Stop()
end
if equipTrack then
equipTrack:Stop()
end
if slashTrack then
slashTrack:Stop()
end
if slash2Track then
slash2Track:Stop()
end
if comboTrack then
comboTrack:Stop()
end
end
-- event listeners
tool.Equipped:Connect(equip)
tool.Unequipped:Connect(dequip)
tool.Activated:Connect(swing)

5 comments
Does it have a handle? If not, consider changing tool.RequiresHandle to false.
it does have a handle
OH, if this matters im using this for an r6 game
what is not working? what point does everything stop working? try putting print() commands after each set of instructions to see where everything stops working. also remember to look for any errors in the output window
You might need to publish your own animations, since other people's animations won't work.