You would probably need to edit the sword script. In the blow(hit)
function you need to check if the player's torso is close to the brick using magnitude. I would not recommend a Touched
or TouchEnded
event due to the fact that many players will be one the brick on once. However, note that magnitude will find the length between the center of the two bricks, so if you have a large brick you may need to play with the magnitude a little bit. It will take some trial and error.
You will also need to name the brick something other than 'Part', so we can access it. I'll assume it is named 'KillingMat'.
02 | if (hit.Parent = = nil ) then return end |
04 | local humanoid = hit.Parent:findFirstChild( "Humanoid" ) |
05 | local vCharacter = Tool.Parent |
06 | local vPlayer = game.Players:playerFromCharacter(vCharacter) |
07 | local hum = vCharacter:findFirstChild( "Humanoid" ) |
08 | if humanoid~ = nil and humanoid ~ = hum and hum ~ = nil then |
11 | if (humanoid.Parent.Torso.Position - workspace.KillingMat.Position).magnitude > 30 then return end |
13 | local right_arm = vCharacter:FindFirstChild( "Right Arm" ) |
14 | if (right_arm ~ = nil ) then |
15 | local joint = right_arm:FindFirstChild( "RightGrip" ) |
16 | if (joint ~ = nil and (joint.Part 0 = = sword or joint.Part 1 = = sword)) then |
17 | tagHumanoid(humanoid, vPlayer) |
18 | humanoid:TakeDamage(damage) |
20 | untagHumanoid(humanoid) |