Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

The punch dont stop taking life when he's supposed to stop anyone help?

I did the animation and everything but every time I press the key with which it is hit, once I press the key with which I press it does not stop taking life, please help

here is the server scrpt :

local Punch = game.ReplicatedStorage local Aniamtion = game.ReplicatedStorage.PunchFolder.Animation

local PDB = false

game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(char) Punch.Punch.OnServerEvent:Connect(function(Player, Action) print("FIRED")

		local humanoid = char:WaitForChild("Humanoid")
		
		char["Left Arm"].Touched:Connect(function(hit)
			if hit.Parent:FindFirstChild("Humanoid") then
				
				hit.Parent.Humanoid:TakeDamage(1)
				wait(1)
				hit.Parent.Humanoid:TakeDamage(0)
			end
		end)		
	end)
end)

end)

local script in the startercharacterscripts

local USI = game:GetService("UserInputService") local player = game.Players.LocalPlayer local char = player.Character local Hum = char:WaitForChild("Humanoid") local dash = game.ReplicatedStorage:WaitForChild("Union"):Clone() local db = false local anim = game.ReplicatedStorage.PunchFolder.Animation

USI.InputBegan:Connect(function(io,p) if io.KeyCode == Enum.KeyCode.R then if db == false then db = true game.ReplicatedStorage.Punch:FireServer() Hum:LoadAnimation(anim):Play() wait(1.2) db = true

	end
end	

end)

1 comment

0

pretty sure that the wait(1) isnt stopping the function from being triggered again

1 answer

When the left arm touches someone, it will damage them. You never made a way to have it only take damage after pressing R. You would need to do it like:

local USI = game:GetService("UserInputService")
local player = game.Players.LocalPlayer 
local char = player.Character
local Hum = char:WaitForChild("Humanoid")
----------------------------------------------------------------
USI.InputBegan:Connect(function(io,p) if io.KeyCode == Enum.KeyCode.R
 local humanoid = char:WaitForChild("Humanoid")

        char["Left Arm"].Touched:Connect(function(hit)
            if hit.Parent:FindFirstChild("Humanoid") then

                hit.Parent.Humanoid:TakeDamage(20)
            end
        end)        
    end)
end)

Along with animations and whatnot. Also, "then if" is supposed to be "and if". Hope that helps.

This discussion is preserved as it was. New answers, comments, and votes are closed.