|
I edited a Linked Sword so that it would deal no damage to anything that had the value "IsShield" in it. But the problem is that the sword hits through the shield and still damages the player, is there a certain way where I can make this work? |
|
|
Change the IsShield's parent to the player's character and check for it there |
|
|
That would work, but I want it so if the sword hits the shield, it negates the damage to the player. |
|
|
I've also tried to add a debounce to the hit function, but it destroys the functionality of a sword. |
|
|
A debounce simply prevents a script from repeating itself due to client/server-side lag. |
|
|
Oh,
If you were simply creating a value for defense, why don't you just divide a global variable for the defense value in the player to all weapons?
|
|
RoflBreadJoin Date: 2009-06-18 Post Count: 3803 |
Grab the players name/instance from the shield via the .Touched event of the sword, and then add it to a table. Then, for the remainder of the sword swing, check if the subsequent .Touched events hit any player in the table, and if any do, deal reduced damage. Reset the table when the sword is activated again.
Though it would probably be better just to stop the swing if the sword hits a shield, as if it's bouncing off. |
|
|
This is what I've got so far, but it's still not working, and nothing appears in the Output.
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
if hit:FindFirstChild("IsShield") ~= nil then
print("HitShield")
local t = {}
table.insert(t, humanoid.Parent.Name)
print(table.concat (t, ' '))
for i = 1,#t do
if (string.upper(humanoid.Parent.Name) == string.upper(t[i])) then return true end
humanoid:TakeDamage(0)
table.remove(t)
wait(1)
untagHumanoid(humanoid)
end
elseif hit:FindFirstChild("IsShield") == nil then
print("NoShield")
humanoid:TakeDamage(damage)
table.remove(t)
wait(1)
untagHumanoid(humanoid)
end
end
end
end
end |
|
|
|
But this is the thread to ask for scripting help .-. |
|
|
|
|
|
|