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

I am creating a punching script, the damage script isn't working the way I want it?

Asked by
xVanc -1
8 years ago

GOAL: PUNCHING SCRIPT ONKEYPRESS - R ANIMATION ACTIVATES THEN DOES DAMAGE (ONLY ON ACTIVATION)

So this damage script is supposed to do damage on activation (onKeyPress) not when it hits direct humanoid.

This damage script is entirely seperate from the main punching script, I will now explain,

PROBLEM:

For example:

If I touch a humanoid while that punching (local) script is in the backpack, it takes damage, it is supposed to do damage on the KeyPress activation, and I don't know any other way..

THE DAMAGE IS A REGULAR SCRIPT, THE PUNCHING SCRIPT IS A LOCAL SCRIPT.

Damage Script:

01Player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
02 
03local char = Player.Character
04local torso = char:findFirstChild("Torso")
05local rightarm = char:findFirstChild("Right Arm")
06 
07function onDamage(rightarm)
08    if rightarm.Parent:FindFirstChild("Humanoid") ~= nil and rightarm.Parent.Name ~= script.Parent.Name then
09        for i = 1,6 do -- change this to change damage
10            rightarm.Parent.Humanoid.Health = rightarm.Parent.Humanoid.Health - 0.8
11            CanCollide = false
12            wait(0.0001)
13        end
14    end
15    wait(0.025)
16end
17 
18rightarm.Touched:connect(onDamage)

The punching localscript is a script that activates an animation and gives XP while cloning the damage script to do damage:

01local UserInputService = game:GetService("UserInputService")
02Player = game.Players.LocalPlayer
03mouse = Player:GetMouse()
04 
05repeat wait() until Player.Character
06 
07local char = Player.Character
08local torso = char:findFirstChild("Torso")
09local leftarm = char:findFirstChild("Left Arm")
10local rightarm = char:findFirstChild("Right Arm")
11 
12enabled = true
13 
14HoldVariable = 0
15 
View all 35 lines...
0
So I have a question, did you make the animation track? If so then the problem can be solved, just let me know.. Radstar1 270 — 8y
0
why dont you put it all in the same script? QuantumToast 261 — 8y
0
@radstar1 what do u mean by animation track @quantumtoast i cant ive tried and it wouldnt work xVanc -1 — 8y

Answer this question