So... I did some giant sword script ( not giant, but for starters it's a bit complex ), it alternates attacks. But... It doesn't works, it simply wont use ( play the animation ) can someone help me? Scripts: equipEvent ( localScript ):~~~~~~~~~~~~~~~~~
script.Parent.Equipped:connect(function(swquip) script.Parent.attackID.Value = 1 script.equipsound:Play() script.Parent.CanDamage.Value = false end)~~~~~~~~~~~~~~~~~
attackScript ( localScript ):~~~~~~~~~~~~~~~~~
local CanAttack = true local attackID = script.Parent.attackID.Value local attack1 = script.Parent.Parent.Humanoid:LoadAnimation(script.attack1) local attack2 = script.Parent.Parent.Humanoid:LoadAnimation(script.attack2) local attack3 = script.Parent.Parent.Humanoid:LoadAnimation(script.attack3) local dmgAble = script.Parent.CanDamage.Value script.Parent.Activated:connect(function() if attackID == 1 and CanAttack == true then attack1:Play() CanAttack = false wait(2) attackID = 2 CanAttack = true dmgAble = true end if attackID == 2 and CanAttack == true then attack2:Play() CanAttack = false wait(3) attackID = 3 CanAttack = true dmgAble = true end if attackID == 3 and CanAttack == true then attack3:Play() CanAttack = false wait(4) CanAttack = true attackID = 1 dmgAble = true end end)~~~~~~~~~~~~~~~~~
damageScript ( Script ):~~~~~~~~~~~~~~~~~
blade = script.Parent.blade attackID = script.Parent.attackID.Value dmgAble = script.Parent.CanDamage.Value blade.Touched:connect(function(targetPlayer) if targetPlayer.Parent:FindFirstChild("Humanoid") and attackID == 1 and dmgAble == true then targetPlayer.Parent.Humanoid:TakeDamage(50) dmgAble = false end if targetPlayer.Parent:FindFirstChild("Humanoid") and attackID == 2 and dmgAble == true then targetPlayer.Parent.Humanoid:TakeDamage(75) dmgAble = false end if targetPlayer.Parent:FindFirstChild("Humanoid") and attackID == 3 and dmgAble == true then targetPlayer.Parent.Humanoid:TakeDamage(200) dmgAble = false end end)~~~~~~~~~~~~~~~~~
CanDamage is a BoolValue attackID is an intValue I really don't know what I missed, the output doesn't gives me any errors... ( ONLY THE THANOS IDLE ANIMATION ERROR lol ) The thing that happens is: The animation wont work, when I use it, nothing happens! ;-; Please tell me what I need to fix or what makes it doesn't work, and... I'm not gonna use it in ROBLOX, only in Studio... Because I know it wont work on the ROBLOX ( Servers ) Sorry bad grammar, I'm brazilian. Oh yeah, the Animation Editor said there's no R15 parts ( I'm using R6, I built the animation on a R6 ), so I'm not sure if that's the problem.
I have got a super easy way to code swords and it doesnt take much effort This sword can damage both npc and players so step number 1 is to insert a on touch damage script into the blade. The script should look lie this:
function onTouched(hit) local human = hit.Parent:findFirstChild("Humanoid") if (human ~= nil) then human.Health = human.Health - 50 end end script.Parent.Touched:connect(onTouched)
and set the script to disabled
now,you want to insert 2 sounds into the tool, a equip sound and a knife slash sound. then just insert a normal script into the tool and type in this
local attk = math.random(1, 5) --- change 5 to the number of attacks script.Parent.Equipped:connect(function() script.Parent.Knife_Equip:Play() end) script.Parent.Activated:connect(function() script.Parent.Blade["Damage Script"].Disabled = false script.Parent.Knife_Slash:Play() if attk == 1 then script.Parent.GripForward = Vector3.new(0,5,- 1) ---change the value in Vector3.new to whatever u want end if attk == 2 then script.Parent.GripForward = Vector3.new(0,5,- 1) ---change the value in Vector3.new to whatever u want end if attk == 3 then script.Parent.GripForward = Vector3.new(0,5,- 1) ---change the value in Vector3.new to whatever u want end if attk == 4 then script.Parent.GripForward = Vector3.new(0,5,- 1) ---change the value in Vector3.new to whatever u want end if attk == 5 then script.Parent.GripForward = Vector3.new(0,5,- 1) ---change the value in Vector3.new to whatever u want end end) script.Parent.Deactivated:connect(function() script.Parent.Blade["Damage Script"].Disabled = true script.Parent.GripForward = Vector3.new(0,0,- 1) end)
then insert another normal script into the tool and this script will be for welding so type in this:
function weld() local parts,last = {} local function scan(parent) for _,v in pairs(parent:GetChildren()) do if (v:IsA("BasePart")) then if (last) then local w = Instance.new("Weld") w.Name = ("%s_Weld"):format(v.Name) w.Part0,w.Part1 = last,v w.C0 = last.CFrame:inverse() w.C1 = v.CFrame:inverse() w.Parent = last end last = v table.insert(parts,v) end scan(v) end end scan(script.Parent) for _,v in pairs(parts) do v.Anchored = false end end weld() script:Remove()
I hope this answer helped! :3