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
|
  |
| 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
|
  |
| Joined: 23 Mar 2009 |
| Total Posts: 619 |
|
| |
|
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 |
|
|
| |
|
| |
|
| |
|
cart6157
|
  |
| Joined: 28 Feb 2009 |
| Total Posts: 2194 |
|
| |
|
| |
|
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 |
|
|
| |
|
lombardo2
|
  |
| Joined: 30 Nov 2008 |
| Total Posts: 1604 |
|
|
| 19 Apr 2012 12:22 AM |
| Cause mine is more editable >:3 |
|
|
| Report Abuse |
|
|
| |
|
lombardo2
|
  |
| Joined: 30 Nov 2008 |
| Total Posts: 1604 |
|
|
| 19 Apr 2012 12:36 AM |
| ok, your is more *dun* :'( |
|
|
| Report Abuse |
|
|
| |
|
lombardo2
|
  |
| Joined: 30 Nov 2008 |
| Total Posts: 1604 |
|
|
| 19 Apr 2012 12:38 AM |
| but i like more *dun* than editable D: |
|
|
| Report Abuse |
|
|
| |
|
KazzzMann
|
  |
| Joined: 23 Mar 2009 |
| Total Posts: 619 |
|
|
| 19 Apr 2012 12:52 AM |
| Oh goodie some replies! Well, time to test! |
|
|
| Report Abuse |
|
|
| |
|
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 |
|
|
| |
|
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
|
  |
| 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
|
  |
| 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 |
|
|
| |
|