generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: How do I make this damage script only dmg to 5% Health?

Previous Thread :: Next Thread 
KazzzMann is not online. KazzzMann
Joined: 23 Mar 2009
Total Posts: 619
18 Apr 2012 10:55 PM
What I'm wanting to make this script do, is only do damage until the player is at 5% of the player's MaxHealth, and will not kill off it's target, but I still want it to do the same damage until it reaches that point. How would I go about doing this?

An example would be is say the part does 100 damage each time it touches a player. And say the player's MaxHealth is 1000. Now say if the player keeps running over the brick, and it's doing 100 damage over and over. 5% of 1000 is 50, so it would continue to do 100 damage until the player's health reaches 100, and since it can't pass 50 (5% of 1000) it would do 50 damage (Because the player's health is at 100, and doing anything over 50 would make the player die), and once the player's health is at 50, the brick cannot damage the player no more.

Before I post the script, I'm just going to say that the part were it says
"local Damage = script.Parent.Dama.Value" There is an int value in the brick were I can juse type in the damage from there. Anyways,

Here's the script:

local debounce = false
local Damage = script.Parent.Dama.Value
local HealthLoss = math.random(1,3) * Damage
function OnTouched(Part)
if Part.Parent ~= nil then
if debounce == false and Part.Parent:findFirstChild("Humanoid") ~= nil then
debounce = true
Part.Parent:findFirstChild("Humanoid"):TakeDamage(HealthLoss)
wait(0.5)
debounce = false
end
end
end
script.Parent.Touched:connect(OnTouched)




Please help, and thank you :)
Report Abuse
iPremiumZ is not online. iPremiumZ
Joined: 23 Jan 2012
Total Posts: 6834
18 Apr 2012 10:58 PM
Easy


script.Parent.Touched:Connect(function(hit)
g = hit.Parent:findFirstChild("Humanoid")
if (g ~= nil) then
for i = 1,5 do
g:TakeDamage(10)
wait()
end
end)
Report Abuse
KazzzMann is not online. KazzzMann
Joined: 23 Mar 2009
Total Posts: 619
18 Apr 2012 11:00 PM
:o Let me test it....
Report Abuse
KazzzMann is not online. KazzzMann
Joined: 23 Mar 2009
Total Posts: 619
18 Apr 2012 11:26 PM
I keep getting:

Script:8: unexpected symbol near ')'

Any help?
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
19 Apr 2012 12:01 AM
[ Content Deleted ]
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
19 Apr 2012 12:04 AM
[ Content Deleted ]
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
19 Apr 2012 12:06 AM
[ Content Deleted ]
Report Abuse
cart6157 is not online. cart6157
Joined: 28 Feb 2009
Total Posts: 2194
19 Apr 2012 12:09 AM
Tipp: x * 0.05 = 5% of x
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
19 Apr 2012 12:13 AM
[ Content Deleted ]
Report Abuse
lombardo2 is not online. lombardo2
Joined: 30 Nov 2008
Total Posts: 1604
19 Apr 2012 12:17 AM
So lets see, you first need to organize your ideas: I want to make a script that damage the player until his health reach 5% then script it

Heres a rough version, feel free to modify it


local debounce = false

function onTouched(part)
local h = part.Parent:FindFirstChild("Humanoid")
local percent = 5 * h.MaxHealth / 100
if h~=nil and h.Health > percent and debounce == false then
h.Health = percent
debounce = true
end
wait(5)
debounce = false
end

script.Parent.Touched:connect(onTouched)
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
19 Apr 2012 12:18 AM
[ Content Deleted ]
Report Abuse
lombardo2 is not online. lombardo2
Joined: 30 Nov 2008
Total Posts: 1604
19 Apr 2012 12:22 AM
Cause mine is more editable >:3
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
19 Apr 2012 12:26 AM
[ Content Deleted ]
Report Abuse
lombardo2 is not online. lombardo2
Joined: 30 Nov 2008
Total Posts: 1604
19 Apr 2012 12:36 AM
ok, your is more *dun* :'(
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
19 Apr 2012 12:37 AM
[ Content Deleted ]
Report Abuse
lombardo2 is not online. lombardo2
Joined: 30 Nov 2008
Total Posts: 1604
19 Apr 2012 12:38 AM
but i like more *dun* than editable D:
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
19 Apr 2012 12:39 AM
[ Content Deleted ]
Report Abuse
KazzzMann is not online. KazzzMann
Joined: 23 Mar 2009
Total Posts: 619
19 Apr 2012 12:52 AM
Oh goodie some replies! Well, time to test!
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
19 Apr 2012 12:55 AM
[ Content Deleted ]
Report Abuse
KazzzMann is not online. KazzzMann
Joined: 23 Mar 2009
Total Posts: 619
19 Apr 2012 01:22 AM
Wood, yours works, but it only does it one time. Any idea why? C:
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
19 Apr 2012 11:19 AM
[ Content Deleted ]
Report Abuse
lombardo2 is not online. lombardo2
Joined: 30 Nov 2008
Total Posts: 1604
19 Apr 2012 11:35 AM
Wat!? are you saying mine doesn't work? >:c. It does works I tested it :C
Report Abuse
lombardo2 is not online. lombardo2
Joined: 30 Nov 2008
Total Posts: 1604
19 Apr 2012 11:53 AM
Oh sorryeh my bad :c fixed version

local debounce = false

function onTouched(hit)
local h = hit.Parent:FindFirstChild("Humanoid")
local percent = h.MaxHealth * 0.05
if h~=nil and h.Health > percent and debounce == false then
h.Health = percent
debounce = true
end
wait(5)
debounce = false
end

script.Parent.Touched:connect(onTouched)
Report Abuse
lombardo2 is not online. lombardo2
Joined: 30 Nov 2008
Total Posts: 1604
19 Apr 2012 12:13 PM
Oh dude im embarrassed the clipboard pasted the unfixed version

local debounce = false
brick = script.Parent

function onTouched(part)
if debounce == false then
local h = part.Parent:findFirstChild("Humanoid")
local percent = h.MaxHealth * 0.05
if h.Health > percent and h ~= nil then
h.Health = percent
debounce = true
end
wait(5)
debounce = false
end
end

brick.Touched:connect(onTouched)

PD= Roblox forums should have an edit button >.>
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
19 Apr 2012 12:17 PM
[ Content Deleted ]
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image