guys i want to script a zombie to kill people and I have an error that make it doesnt damage players please help me there is the script:
01 | local rarm = script.Parent:FindFirstChild( "Right Arm" ) |
02 | local larm = script.Parent:FindFirstChild( "Left Arm" ) |
03 |
04 | function dmg(hit) |
05 | if hit.Parent ~ = nil then |
06 | local hum = hit.Parent:findFirstChild( "Humanoid" ) |
07 | if hum ~ = nil then |
08 | hum.Health = hum.Health - 10 |
09 | end |
10 | end |
11 | end |
12 |
13 | rarm.Touched:connect(dmg) |
14 | larm.Touched:connect(dmg) |
You have created a function that requires a parameter, but you are calling it without giving it the required parameter.
Try this:
01 | local rarm = script.Parent:FindFirstChild( "Right Arm" ) |
02 | local larm = script.Parent:FindFirstChild( "Left Arm" ) |
03 |
04 | rarm.Touched:connect( function (Hit) -- So I can get the parameter(Hit) |
05 | if hit.Parent ~ = nil then |
06 | local hum = hit.Parent:findFirstChild( "Humanoid" ) |
07 | if hum ~ = nil then |
08 | hum.Health = hum.Health - 10 |
09 | end |
10 | end |
11 | end ) |
12 |
13 | larm.Touched:connect( function (Hit) -- So I can get the parameter(Hit) |
14 | if hit.Parent ~ = nil then |
15 | local hum = hit.Parent:findFirstChild( "Humanoid" ) |
16 | if hum ~ = nil then |
17 | hum.Health = hum.Health - 10 |
18 | end |
19 | end |
20 | end ) |
01 | local rarm = script.Parent:WaitForChild( "Right Arm" ) -- WaitForChild is waiting for that object until its loaded, you problem was that "rarm" or "larm" doesnt exist |
02 | local larm = script.Parent:WaitForChild( "Left Arm" ) |
03 |
04 | function dmg(hit) |
05 | if hit.Parent ~ = nil then |
06 | local hum = hit.Parent:findFirstChild( "Humanoid" ) |
07 | if hum ~ = nil then |
08 | hum.Health = hum.Health - 10 |
09 | end |
10 | end |
11 | end |
12 |
13 | rarm.Touched:connect(dmg) |
14 | larm.Touched:connect(dmg) |