Hey, guys. I am trying to make a localscript that whenever Player A presses "f", it does a little animation, and any other players that touches Player A's right arm will lose 70 health. The following is in a Localscript, inside StarterPack:
Player = game.Players.LocalPlayer mouse = Player:GetMouse() db = false function onKeyDown(key) key = key:lower() if db == false then db = true if key == "f" then -- when F is pressed... --Make a little animation. local RightShoulder = Player.Character.Torso["Right Shoulder"] local LeftShoulder = Player.Character.Torso["Left Shoulder"] for i = 1,10 do RightShoulder.C0 = RightShoulder.C0 * CFrame.Angles(0,0,0.5) LeftShoulder.C0 = LeftShoulder.C0 * CFrame.Angles(0,0,-0.5) wait(0.001) end for i = 1,10 do RightShoulder.C0 = RightShoulder.C0 * CFrame.Angles(-0.5,0,0) LeftShoulder.C0 = LeftShoulder.C0 * CFrame.Angles(-0.5,0,0) wait(0.001) end for i = 1,10 do RightShoulder.C0 = RightShoulder.C0 * CFrame.Angles(0.5,0,0) LeftShoulder.C0 = LeftShoulder.C0 * CFrame.Angles(0.5,0,0) wait(0.001) end for i = 1,10 do RightShoulder.C0 = RightShoulder.C0 * CFrame.Angles(0,0,-0.5) LeftShoulder.C0 = LeftShoulder.C0 * CFrame.Angles(0,0,0.5) wait(0.001) end --locate the player's right arm and damage whomever touches it local RightArm = Player.Character["Right Arm"] local p = game.Players:FindFirstChild(RightArm.Touched.Name) if p and p.Character.Humanoid then p.Character.Humanoid.Health = p.Character.Humanoid.Health - 70 end end db = false end end mouse.KeyDown:connect(onKeyDown)
If anyone could tell me what I did wrong, I would highly appreciate it! ALSO: The animation part works fine. The only problem is that it doesn't do damage to others.
Thanks!