sgccode9
|
  |
| Joined: 15 Dec 2007 |
| Total Posts: 1048 |
|
|
| 18 Nov 2011 11:09 PM |
I'm trying to figure out how a basic sword script could be modified to damage both humans and zombies.
I'm sure its easy to make or edit but I'm not the best scripter around ^_^.
So, heres the basic sword script:
%B7Yc4g3cVF2vsIKTu48R1nScXPd5Vo60+xN0Q76AakHULM5fe1mr5zRUX5JSWoGHEo1edTgpe64xv21qdoLhD/SPEfbcHqsq1yly+4qaywNLH/YfQ7Hg7BosLHdrvJ45miA7slD6WHxMwAIne/oTw6Xs2G7dH4j1MSnDIsxiy8I=%%1014475%-------- OMG HAX
r = game:service("RunService")
local damage = 5
local slash_damage = 10 local lunge_damage = 30
sword = script.Parent.Handle Tool = script.Parent
local SlashSound = Instance.new("Sound") SlashSound.SoundId = "rbxasset://sounds\\swordslash.wav" SlashSound.Parent = sword SlashSound.Volume = .7
local LungeSound = Instance.new("Sound") LungeSound.SoundId = "rbxasset://sounds\\swordlunge.wav" LungeSound.Parent = sword LungeSound.Volume = .6
local UnsheathSound = Instance.new("Sound") UnsheathSound.SoundId = "rbxasset://sounds\\unsheath.wav" UnsheathSound.Parent = sword UnsheathSound.Volume = 1
function blow(hit) if (hit.Parent == nil) then return end -- happens when bullet hits sword
local humanoid = hit.Parent:findFirstChild("Humanoid") 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) humanoid:TakeDamage(damage) wait(1) untagHumanoid(humanoid) end 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() local anim = Instance.new("StringValue") anim.Name = "toolanim" anim.Value = "Slash" anim.Parent = Tool end
function lunge() damage = lunge_damage
LungeSound:play()
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 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
t = r.Stepped:wait()
if (t - last_attack < .2) then lunge() else attack() end
last_attack = t
--wait(.5)
Tool.Enabled = true end
function onEquipped() UnsheathSound:play() end
script.Parent.Activated:connect(onActivated) script.Parent.Equipped:connect(onEquipped)
connection = sword.Touched:connect(blow)
-----------
Any help would be appreciated! |
|
|
| Report Abuse |
|
|
Lowcart
|
  |
| Joined: 12 Sep 2011 |
| Total Posts: 1323 |
|
| |
|
sgccode9
|
  |
| Joined: 15 Dec 2007 |
| Total Posts: 1048 |
|
|
| 18 Nov 2011 11:12 PM |
| Yes, but how can I make it damage BOTH humans and zombies, rather than just one variable. |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2011 11:12 PM |
| It already will do damage to zombies, assuming the zombies' Humanoid name is "Humanoid". Otherwise, you will have to make it search for the zombies humanoid name that you set. |
|
|
| Report Abuse |
|
|
sgccode9
|
  |
| Joined: 15 Dec 2007 |
| Total Posts: 1048 |
|
|
| 18 Nov 2011 11:14 PM |
Yes, the zombie's Humanoid name is "Zombie"
So how can I make it damage both "Humanoid" and "Zombie" |
|
|
| Report Abuse |
|
|
Lowcart
|
  |
| Joined: 12 Sep 2011 |
| Total Posts: 1323 |
|
| |
|
|
| 18 Nov 2011 11:15 PM |
local humanoid = hit.Parent:findFirstChild("Humanoid") or hit.Parent:FindFirstChild("Zombie")
Change that in the `function blow()` |
|
|
| Report Abuse |
|
|
coolbob44
|
  |
| Joined: 26 Nov 2009 |
| Total Posts: 1649 |
|
|
| 18 Nov 2011 11:15 PM |
--Make model the zombie's model
for i, v in pairs(model:children()) do if v:IsA("Humanoid") v:takeDamage(15) end end |
|
|
| Report Abuse |
|
|
Lowcart
|
  |
| Joined: 12 Sep 2011 |
| Total Posts: 1323 |
|
| |
|
coolbob44
|
  |
| Joined: 26 Nov 2009 |
| Total Posts: 1649 |
|
| |
|
|
| 18 Nov 2011 11:17 PM |
@cool
No, your method is better. It makes it so he can change the zombie's humanoid name and it would still work. |
|
|
| Report Abuse |
|
|
coolbob44
|
  |
| Joined: 26 Nov 2009 |
| Total Posts: 1649 |
|
| |
|
| |
|
|
| 18 Nov 2011 11:19 PM |
| Oh I just noticed, you forgot to put a `then` at the end of the if statement... :D |
|
|
| Report Abuse |
|
|
sgccode9
|
  |
| Joined: 15 Dec 2007 |
| Total Posts: 1048 |
|
|
| 18 Nov 2011 11:20 PM |
@TheNewScripter..
No dice.. it does what any other broken tool does, stops working Dx. |
|
|
| Report Abuse |
|
|
coolbob44
|
  |
| Joined: 26 Nov 2009 |
| Total Posts: 1649 |
|
|
| 18 Nov 2011 11:20 PM |
| I do that all the time. I code in PHP too much :P |
|
|
| Report Abuse |
|
|
sgccode9
|
  |
| Joined: 15 Dec 2007 |
| Total Posts: 1048 |
|
|
| 18 Nov 2011 11:20 PM |
| Oops, more replies, hold on then :D |
|
|
| Report Abuse |
|
|
coolbob44
|
  |
| Joined: 26 Nov 2009 |
| Total Posts: 1649 |
|
|
| 18 Nov 2011 11:20 PM |
--Make model the zombie's model
for i, v in pairs(model:children()) do if v:IsA("Humanoid") then v:takeDamage(15) end end
---FLOODCHECK, BE GONE |
|
|
| Report Abuse |
|
|
Lowcart
|
  |
| Joined: 12 Sep 2011 |
| Total Posts: 1323 |
|
| |
|
sgccode9
|
  |
| Joined: 15 Dec 2007 |
| Total Posts: 1048 |
|
|
| 18 Nov 2011 11:21 PM |
| @Coolbob - Could you explain that script a little more and where its supposed to go? |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2011 11:21 PM |
| Lowcart, stop trolling plz. |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2011 11:22 PM |
@low
WRONG. Based off what you just said, this code will only run once:
for i = 1, 100000 do print("This code has ran: " .. i) end |
|
|
| Report Abuse |
|
|
Lowcart
|
  |
| Joined: 12 Sep 2011 |
| Total Posts: 1323 |
|
| |
|
coolbob44
|
  |
| Joined: 26 Nov 2009 |
| Total Posts: 1649 |
|
|
| 18 Nov 2011 11:23 PM |
Here's your new blow function
function blow(hit) if (hit.Parent == nil) then return end -- happens when bullet hits sword
for i, v in pairs(hit.Parent:children()) do if v:IsA("Humanoid") then humanoid=v end end
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) humanoid:TakeDamage(damage) wait(1) untagHumanoid(humanoid) end end
end end |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2011 11:23 PM |
| @TNS - I'm sure he knows that, he's probably trolling. He knows how to script. :P |
|
|
| Report Abuse |
|
|