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

Not taking tat much damage?

This script takes away 100 health. I want it to take away 50%

script.Parent.Touched:connect(function(Obj) -- When you touch it gets the "Leg" or "Arm"
    local Player = game:GetService("Players"):GetPlayerFromCharacter(Obj.Parent)
    -- Gets the Instance "Player"
    if Player and Player.Character then -- Obv its gonna be there...
        local Humanoid  = Player.Character:WaitForChild("Humanoid") -- Find the Humanoid
        Humanoid:TakeDamage(50) -- Easy damage function.. :)
    end
 end)

1 comment

0

http://wiki.roblox.com/index.php?title=Debounce has good info & it probably applies to this situation.

1 answer

you need a debounce, you hit a part like 1 million times in a second, it probaly works, the script is called tonns of times

debounce = false
script.Parent.Touched:connect(function(Obj)
	if debounce == false then
		debounce = true
		local Player = game:GetService("Players"):GetPlayerFromCharacter(Obj.Parent)
			if Player and Player.Character then
				local Humanoid  = Player.Character:WaitForChild("Humanoid")
				Humanoid:TakeDamage(50) 
				wait(3)
				debounce = false
			end
	end
end)

:) try this for half damage

debounce = false
script.Parent.Touched:connect(function(Obj)
	if debounce == false then
		local Player = game:GetService("Players"):GetPlayerFromCharacter(Obj.Parent)
			if Player and Player.Character then
				local Humanoid  = Player.Character:WaitForChild("Humanoid")
				local damage = Humanoid.Maxhealth/2
				Humanoid:TakeDamage(damage) 
				debounce = true
			end
	end
end)

1 comment

0

I agree, add a debounce.

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