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

Not taking tat much damage?

Asked by
FiredDusk 1466 Moderation Voter
9 years ago

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

1script.Parent.Touched:connect(function(Obj) -- When you touch it gets the "Leg" or "Arm"
2    local Player = game:GetService("Players"):GetPlayerFromCharacter(Obj.Parent)
3    -- Gets the Instance "Player"
4    if Player and Player.Character then -- Obv its gonna be there...
5        local Humanoid  = Player.Character:WaitForChild("Humanoid") -- Find the Humanoid
6        Humanoid:TakeDamage(50) -- Easy damage function.. :)
7    end
8 end)
0
http://wiki.roblox.com/index.php?title=Debounce has good info & it probably applies to this situation. Redbullusa 1580 — 9y

1 answer

Log in to vote
2
Answered by 9 years ago

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

01debounce = false
02script.Parent.Touched:connect(function(Obj)
03    if debounce == false then
04        debounce = true
05        local Player = game:GetService("Players"):GetPlayerFromCharacter(Obj.Parent)
06            if Player and Player.Character then
07                local Humanoid  = Player.Character:WaitForChild("Humanoid")
08                Humanoid:TakeDamage(50)
09                wait(3)
10                debounce = false
11            end
12    end
13end)

:) try this for half damage

01debounce = false
02script.Parent.Touched:connect(function(Obj)
03    if debounce == false then
04        local Player = game:GetService("Players"):GetPlayerFromCharacter(Obj.Parent)
05            if Player and Player.Character then
06                local Humanoid  = Player.Character:WaitForChild("Humanoid")
07                local damage = Humanoid.Maxhealth/2
08                Humanoid:TakeDamage(damage)
09                debounce = true
10            end
11    end
12end)
0
I agree, add a debounce. JasonTheOwner 391 — 9y
Ad

Answer this question