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

Which does .Touched always work after i click Q or E once?

Asked by 7 years ago

I made this script which when you click the either Q or E. Will play up an animation, then if a player touches the body part, then it damage them from a remote function. But once i click Q or E {Punching and Kicking} You could damage the player infinitely, what i ment is after 1 click of Q and E and you can keep the touching the target player and they will die. I tried to add a disconnect line when they touch a player / NPC, then you can't damage them until you click Q or E again.

    if input.KeyCode == Enum.KeyCode.Q and player.Character and player.Character.Humanoid.Health > 0 and not chat and not action and not punchdebounce and not kickdebounce and not releasedebounce then
                punchdebounce = true
                action = true
            local checkplaying = checkstat:InvokeServer("Playing", "BaseValue")         
            local checkvalue = checkstat:InvokeServer("Eternity", "BaseValue")  
            if checkplaying == true and checkvalue >= 0 then

                PlayAnimation(animations[1], sounds[1], "Punch")        
                changestat:InvokeServer("Exp", punchexp * expmultiplier.Value, "Add")

--MAIN TOUCHING SCRIPT IS HERE

touch1 = player.Character:WaitForChild("LeftLowerArm").Touched:connect(function(part)
    if touch == false and part.Parent:FindFirstChild("STATSFOLDER") or             part.Parent:FindFirstChild("Health") then
    touch = true
    damagefunction:InvokeServer(part.Parent, "Punch")
    touch1:disconnect()
    end
end)        

touch2 = player.Character:WaitForChild("RightLowerArm").Touched:connect(function(part)
    if rtouch == false and part.Parent:FindFirstChild("STATSFOLDER") or part.Parent:FindFirstChild("Health") then
    rtouch = true
    damagefunction:InvokeServer(part.Parent, "Kick")
    touch2:disconnect()
    end
end)            

    wait(waitperattack)
    punchdebounce = false
    touch = false
    rtouch = false      
    else
        punchdebounce = false
        action = false                      
    end         
end

-MAIN TOUCHING SCRIPT ENDS HERE

I hope this is informative enough c:

0
They're suppose to be debounces xXOverLord34Xx 8 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Looks like your touch1 coding and touch2 have spelling errors. In touch to find code, rtouch = true Typo right there and touch1 on top part doesn't match touch = true segment forgot to place the 1 after touch. See if that helped. My phone screens to small to see your code completely

Ad

Answer this question