Linkmon99
|
  |
| Joined: 11 Feb 2009 |
| Total Posts: 29662 |
|
|
| 22 Jul 2012 02:32 PM |
So I made all the humaniods on the enemies a "Enemy". This made it so the sword will not kill other players and only the "Enemy". What do I change? ---
r = game:service("RunService")
local damage = 0
local slash_damage = 7 local lunge_damage = 7
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() end
function lunge() damage = lunge_damage
local vCharacter = Tool.Parent local hum = vCharacter:findFirstChild("Humanoid")
if hum then hum.Jump = false end wait(.5) LungeSound:play() wait(.3)
damage = slash_damage 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(.8) lunge()
Tool.Enabled = true end
function onEquipped() UnsheathSound:play() end
script.Parent.Activated:connect(onActivated) script.Parent.Equipped:connect(onEquipped)
connection = sword.Touched:connect(blow)
|
|
|
| Report Abuse |
|
|
Solotaire
|
  |
| Joined: 30 Jul 2009 |
| Total Posts: 30356 |
|
|
| 22 Jul 2012 02:34 PM |
local humanoid = hit.Parent:findFirstChild("Enemy")
|
|
|
| Report Abuse |
|
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
|
| 22 Jul 2012 02:34 PM |
Wherever it says ...:findFirstChild("Humanoid") change it to ...:FindFirstChild("Enemy") |
|
|
| Report Abuse |
|
|
Solotaire
|
  |
| Joined: 30 Jul 2009 |
| Total Posts: 30356 |
|
|
| 22 Jul 2012 02:41 PM |
"Wherever it says" No, only the one. The other two times are trying to reference your own Humanoid. |
|
|
| Report Abuse |
|
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
|
| 22 Jul 2012 02:42 PM |
Guess you're right. *shrug*
I haven't read through the LinkedSword script in ever. |
|
|
| Report Abuse |
|
|
Linkmon99
|
  |
| Joined: 11 Feb 2009 |
| Total Posts: 29662 |
|
|
| 22 Jul 2012 02:48 PM |
| Thanks but now I have some more problems |
|
|
| Report Abuse |
|
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
|
| 22 Jul 2012 02:49 PM |
Ooh, problems are bad.
But it looks like we have nothing to do here since you won't share them. |
|
|
| Report Abuse |
|
|
Linkmon99
|
  |
| Joined: 11 Feb 2009 |
| Total Posts: 29662 |
|
|
| 22 Jul 2012 02:51 PM |
Here they are :P Well basically now that I have switched all the enemies humanoids to Enemy, their animations dont work and they wont respawn, scripts: name="Humanoid"
robo=script.Parent:clone()
while true do
wait(6)--the time period between death and rebirth.
if script.Parent.Humanoid.Health<1 then
robot=robo:clone()
robot.Parent=script.Parent.Parent
robot:makeJoints()
script.Parent:remove()
end
end ----- function findNearestTorso(pos) local list = game.Workspace:children() local torso = nil local dist = 10 --this is the distance your monster will see you local temp = nil local human = nil local temp2 = nil for x = 1, #list do temp2 = list[x] if (temp2.className == "Model") and (temp2 ~= script.Parent) then temp = temp2:findFirstChild("Torso") human = temp2:findFirstChild("Humanoid") if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then if (temp.Position - pos).magnitude < dist then torso = temp dist = (temp.Position - pos).magnitude end end end end return torso end
while true do wait(0.1) local target = findNearestTorso(script.Parent.Torso.Position) if target ~= nil then-- script.Parent.Enemy:MoveTo(target.Position, target) end end |
|
|
| Report Abuse |
|
|
Linkmon99
|
  |
| Joined: 11 Feb 2009 |
| Total Posts: 29662 |
|
|
| 22 Jul 2012 02:53 PM |
| Like what should I be changing and what not. |
|
|
| Report Abuse |
|
|