Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Weapon script dosn't deflect damage, why?

Asked by 7 years ago

I'm trying to make a weapon, it swings but it doesn't do any damage,when I had the script print what the argument was, it said terrain.

console

Terrain 18:33:52.341 - Humanoid is not a valid member of Workspace 18:33:52.342 - Stack Begin 18:33:52.343 - Script 'Players.Player2.Backpack.axe.damage', Line 5 18:33:52.344 - Stack End

script

1script.Parent.hitbox.Touched:connect(function(p)
2    if script.Parent.CanDamage.Value == true then
3        print(p)
4        script.Parent.CanDamage.Value = false
5        p.Parent.Humanoid:TakeDamage(20)
6    end
7end)

local script

01local CanAttack = true
02 
03script.Parent.Activated:connect(function()
04 
05local attack = script.Parent.Parent.Humanoid:LoadAnimation(script.Attack)
06 
07if CanAttack == true then
08script.Parent.CanDamage.Value = true
09game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0
10attack:Play()
11 
12CanAttack = false
13 
14wait(0.4)
15 
View all 24 lines...

welding script (in case)

001local NEVER_BREAK_JOINTS = false
002 
003local function CallOnChildren(Instance, FunctionToCall)
004 
005    FunctionToCall(Instance)
006 
007    for _, Child in next, Instance:GetChildren() do
008        CallOnChildren(Child, FunctionToCall)
009    end
010end
011 
012local function GetNearestParent(Instance, ClassName)
013 
014    local Ancestor = Instance
015    repeat
View all 174 lines...
0
Error messages explain a lot most of the time.  hiimgoodpack 2009 — 7y

2 answers

Log in to vote
1
Answered by 7 years ago

I think there are two possibilities,

One possibility is that it's actually hitting the terrain in your map, and therefore it's not able to find a humanoid in the workspace which is Hit.Parent

Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

I'm not exactly sure but when the touched function fires, I think it reads the entire model (the character). So when you said p.Parent, the character models Parent is a obviously the workspace. My point is, take out the Parent part so it is p.Humanoid:TakeDamage(20)

0
Depends what hit it in the first place Pejorem 164 — 7y
0
it is now saying terrain, and btw, it never hits the physical ground, I have the axe go inside the player with no animation and it still says terrain 19:37:52.412 - Humanoid is not a valid member of Terrain 19:37:52.413 - Stack Begin | 19:37:52.414 - Script 'Players.Player1.Backpack.axe.damage', Line 7 | 19:37:52.415 - Stack End ninja_eaglegamer 61 — 7y

Answer this question