wally5026
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 503 |
|
|
| 14 Aug 2013 07:09 PM |
This Script works for 1 sword hit and then it breaks and the sword no longer does damage.
r = game:service("RunService") ching = false sword = script.Parent.Handle Tool = script.Parent function blow(hit) if ching == true then return end local humanoid = hit.Parent:findFirstChild("Humanoid") local vCharacter = Tool.Parent local vPlayer = game.Players:playerFromCharacter(vCharacter) if humanoid~=nil then ching = true print("SWORD HIT") tagHumanoid(humanoid, vPlayer) local damage = math.random(script.Parent.MinDmg.Value+math.floor(vPlayer.attributes.Strength.Value/5),script.Parent.MaxDmg.Value+math.floor(vPlayer.attributes.Strength.Value/5))+math.floor(vPlayer.leaderstats.Lvl.Value/5) humanoid:TakeDamage(damage) local part = Instance.new("ScreenGui") local part2 = Instance.new("TextLabel") c1 = script.FadeClean:Clone() c2 = script.TextRiser:Clone() part2.FontSize = "Size24" part2.Font = "ArialBold" part2.Size = UDim2.new(0,50,0,50) part2.Position = UDim2.new(0.5,0,0.25,0) part2.BackgroundTransparency = 1 part2.Parent = part c1.Parent = part2 c1.Disabled = false c2.Parent = part2 c2.Disabled = false part.Parent = vPlayer.PlayerGui if (damage == 0) then part2.TextColor3 = Color3.new(0/255,102/255,255/255) else part2.TextColor3 = Color3.new(255/255,255/255,255/255) end part2.Text = ""..damage.."" wait(1) ching = false wait(.1) untagHumanoid(humanoid) 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() local anim = Instance.new("StringValue") anim.Name = "toolanim" anim.Value = "Slash" anim.Parent = Tool end function lunge() local anim = Instance.new("StringValue") anim.Name = "toolanim" anim.Value = "Lunge" anim.Parent = Tool force = Instance.new("BodyVelocity") force.velocity = Vector3.new(0,10,0) --Tool.Parent.Torso.CFrame.lookVector * 80 force.Parent = Tool.Parent.Torso wait(.25) swordOut() wait(.25) force.Parent = nil wait(.5) swordUp() damage = slash_damage end function swordUp() Tool.GripForward = Vector3.new(-1,0,0) Tool.GripRight = Vector3.new(0,1,0) Tool.GripUp = Vector3.new(0,0,1) end function swordOut() Tool.GripForward = Vector3.new(0,0,1) Tool.GripRight = Vector3.new(0,-1,0) Tool.GripUp = Vector3.new(-1,0,0) end function swordAcross() -- parry end Tool.Enabled = true 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() end script.Parent.Activated:connect(onActivated) script.Parent.Equipped:connect(onEquipped) connection = sword.Touched:connect(blow) |
|
|
| Report Abuse |
|
|
ShagFace
|
  |
| Joined: 22 Aug 2011 |
| Total Posts: 3474 |
|
|
| 14 Aug 2013 07:28 PM |
The second "ching" in the script, needs to be false. Because the Humanoid won't ~= nil, because of its health
I think that may be what causes your script to be inoperable If not, then I think the script may just be too long and complex, for an individual object to carry, therefore making it crash. |
|
|
| Report Abuse |
|
|
|
| 14 Aug 2013 07:30 PM |
Here,
r = game:service("RunService") ching = false sword = script.Parent.Handle Tool = script.Parent function blow(hit) if ching == true then return end local humanoid = hit.Parent:findFirstChild("Humanoid") local vCharacter = Tool.Parent local vPlayer = game.Players:playerFromCharacter(vCharacter) if humanoid~=nil then ching = false print("SWORD HIT") tagHumanoid(humanoid, vPlayer) local damage = math.random(script.Parent.MinDmg.Value+math.floor(vPlayer.attributes.Strength.Value/5),script.Parent.MaxDmg.Value+math.floor(vPlayer.attributes.Strength.Value/5))+math.floor(vPlayer.leaderstats.Lvl.Value/5) humanoid:TakeDamage(damage) local part = Instance.new("ScreenGui") local part2 = Instance.new("TextLabel") c1 = script.FadeClean:Clone() c2 = script.TextRiser:Clone() part2.FontSize = "Size24" part2.Font = "ArialBold" part2.Size = UDim2.new(0,50,0,50) part2.Position = UDim2.new(0.5,0,0.25,0) part2.BackgroundTransparency = 1 part2.Parent = part c1.Parent = part2 c1.Disabled = false c2.Parent = part2 c2.Disabled = false part.Parent = vPlayer.PlayerGui if (damage == 0) then part2.TextColor3 = Color3.new(0/255,102/255,255/255) else part2.TextColor3 = Color3.new(255/255,255/255,255/255) end part2.Text = ""..damage.."" wait(1) ching = false wait(.1) untagHumanoid(humanoid) 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() local anim = Instance.new("StringValue") anim.Name = "toolanim" anim.Value = "Slash" anim.Parent = Tool end
function lunge()
local anim = Instance.new("StringValue") anim.Name = "toolanim" anim.Value = "Lunge" anim.Parent = Tool
force = Instance.new("BodyVelocity") force.velocity = Vector3.new(0,10,0) --Tool.Parent.Torso.CFrame.lookVector * 80 force.Parent = Tool.Parent.Torso wait(.25) swordOut() wait(.25) force.Parent = nil wait(.5) swordUp()
damage = slash_damage end
function swordUp() Tool.GripForward = Vector3.new(-1,0,0) Tool.GripRight = Vector3.new(0,1,0) Tool.GripUp = Vector3.new(0,0,1) end
function swordOut() Tool.GripForward = Vector3.new(0,0,1) Tool.GripRight = Vector3.new(0,-1,0) Tool.GripUp = Vector3.new(-1,0,0) end
function swordAcross() -- parry end
Tool.Enabled = true
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()
end
script.Parent.Activated:connect(onActivated) script.Parent.Equipped:connect(onEquipped)
connection = sword.Touched:connect(blow) |
|
|
| Report Abuse |
|
|
MHebes
|
  |
| Joined: 04 Jan 2013 |
| Total Posts: 2278 |
|
|
| 14 Aug 2013 07:30 PM |
"I think the script may just be too long and complex, for an individual object to carry, therefore making it crash." That doesn't really happen.
~ Oh, I'm sorry, did I break your concentration? ~ |
|
|
| Report Abuse |
|
|