It's a chainsaw script, and I'm trying to make it keep going while you're holding down the left mouse button.
r = game:service("RunService")
local damage = 10
local slash_damage = 25
sword = script.Parent.Handle
Tool = script.Parent
Slashing = false
local SlashSound = Instance.new("Sound")
SlashSound.SoundId = "http://www.roblox.com/asset/?id=2766576"
SlashSound.Parent = sword
SlashSound.Volume = 1
SlashSound.Pitch = 1
function blow(hit)
if (hit.Parent == nil) then return end -- happens when bullet hits sword
local humanoid = hit.Parent:findFirstChild("Zombie")
local vCharacter = Tool.Parent
local vPlayer = game.Players:playerFromCharacter(vCharacter)
local hum = vCharacter:findFirstChild("Humanoid") -- non-nil if tool held by a character
if humanoid~=nil and humanoid ~= hum and hum ~= nil then
-- final check, make sure sword is in-hand
local right_arm = vCharacter:FindFirstChild("Right Arm")
if (right_arm ~= nil) then
local joint = right_arm:FindFirstChild("RightGrip")
if (joint ~= nil and (joint.Part0 == sword or joint.Part1 == sword)) then
tagHumanoid(humanoid, vPlayer)
if Slashing == false then
Slashing = true
if hit.Name == "Head" or hit.Name == "Torso" then
print'CARNAGE!'
humanoid:TakeDamage(damage)
Tool.Blade.Hit:Play()
if hit.Parent:FindFirstChild("Torso") then
hit.Parent.Torso.RotVelocity = hit.Parent.Torso.RotVelocity + Vector3.new(math.random(-30,30),math.random(-30,30),math.random(-30,30))
end
Tool.Bloodeh.Bloodieh.Enabled = true
untagHumanoid(humanoid)
wait(.1)
Slashing = false
elseif hit.Name == "Left Arm" or hit.Name == "Right Arm" or hit.Name == "Left Leg" or hit.Name == "Right Leg" then
print'Limb-Taking!'
humanoid:TakeDamage(damage * .8)
Tool.Blade.Hit:Play()
if hit.Parent:FindFirstChild("Torso") then
hit.Parent.Torso.RotVelocity = hit.Parent.Torso.RotVelocity + Vector3.new(math.random(-15,15),math.random(-15,15),math.random(-15,15))
end
Tool.Bloodeh.Bloodieh.Enabled = true
untagHumanoid(humanoid)
wait(.1)
Slashing = false
else
print'ARMORED...'
humanoid:TakeDamage(damage * .2)
Tool.Blade.Hit:Play()
if hit.Parent:FindFirstChild("Torso") then
hit.Parent.Torso.RotVelocity = hit.Parent.Torso.RotVelocity + Vector3.new(math.random(-5,5),math.random(-5,5),math.random(-5,5))
end
Tool.Bloodeh.Bloodieh.Enabled = true
Tool.Bloodeh.Materialleh.Enabled = true
untagHumanoid(humanoid)
wait(.1)
Slashing = false
end
end
end
end
elseif humanoid == nil and hum ~= nil then
if hit.Transparency ~= 1 and hit.CanCollide ~= false then
Tool.Bloodeh.OtherMaterialleh.Enabled = true
Tool.Bloodeh.Materialleh.Enabled = true
end
end
end
function tagHumanoid(humanoid, player)
local creator_tag = Instance.new("ObjectValue")
creator_tag.Value = player
creator_tag.Name = "creator"
creator_tag.Parent = humanoid
end
function untagHumanoid(humanoid)
if humanoid ~= nil then
local tag = humanoid:findFirstChild("creator")
if tag ~= nil then
tag.Parent = nil
end
end
end
function attack()
damage = slash_damage
SlashSound:play()
Slash()
end
function Slash()
Tool.GripForward = Vector3.new(-1,0.2,0)
Tool.GripPos = Vector3.new(0,0.1,0)
wait()
Tool.GripForward = Vector3.new(-1,0.4,0)
Tool.GripPos = Vector3.new(0,0.2,0)
wait()
Tool.GripForward = Vector3.new(-1,0.5,0)
Tool.GripPos = Vector3.new(0,0.3,0)
wait()
Tool.GripForward = Vector3.new(-1,0.8,0)
Tool.GripPos = Vector3.new(0,0.4,0)
wait()
Tool.GripForward = Vector3.new(-1,1,0)
Tool.GripPos = Vector3.new(0,0.5,0)
wait()
Tool.GripForward = Vector3.new(-1,0.8,0)
Tool.GripPos = Vector3.new(0,0.4,0)
wait()
Tool.GripForward = Vector3.new(-1,0.6,0)
Tool.GripPos = Vector3.new(0,0.3,0)
wait()
Tool.GripForward = Vector3.new(-1,0.4,0)
Tool.GripPos = Vector3.new(0,0.2,0)
wait()
Tool.GripForward = Vector3.new(-1,0.2,0)
Tool.GripPos = Vector3.new(0,0.1,0)
wait()
Tool.GripForward = Vector3.new(-1,0.0,0)
Tool.GripPos = Vector3.new(0,0,0)
wait()
end
Tool.Enabled = true
local last_attack = 0
function onActivated()
if not Tool.Enabled then
return
end
Tool.Enabled = false
local character = Tool.Parent;
local humanoid = character.Humanoid
if humanoid == nil then
print("Humanoid not found")
return
end
attack()
wait(.1)
Tool.Enabled = true
end
function onEquipped()
sword.Start:Play()
sword.Idle:Play()
end
function onUnequipped()
sword.Idle:Stop()
end
function stopTouching(hit)
if (hit.Parent == nil) then return end
local humanoid = hit.Parent:findFirstChild("Zombie")
if humanoid~=nil then
if hit.Name == "Head" or hit.Name == "Torso" or hit.Name == "Left Arm" or hit.Name == "Right Arm" or hit.Name == "Left Leg" or hit.Name == "Right Leg" then
wait(.5)
Tool.Bloodeh.Bloodieh.Enabled = false
else
wait(.5)
Tool.Bloodeh.Bloodieh.Enabled = false
Tool.Bloodeh.Materialleh.Enabled = false
end
else
if hit.Transparency ~= 1 and hit.CanCollide ~= false then
Tool.Bloodeh.OtherMaterialleh.Enabled = false
Tool.Bloodeh.Materialleh.Enabled = false
end
end
end
script.Parent.Activated:connect(onActivated)
script.Parent.Equipped:connect(onEquipped)
script.Parent.Unequipped:connect(onUnequipped)
connection = Tool.Blade.Touched:connect(blow)
Tool.Blade.TouchEnded:connect(stopTouching)

1 comment
Short and simple script, huh..