Poomuffin
|
  |
| Joined: 13 Mar 2010 |
| Total Posts: 11369 |
|
|
| 13 Oct 2013 05:25 PM |
so like it gives you a ratio of hp to max hp n junk when you equip the shield except im using this in a rpg game, with the players health changing constantly (when they lvl up) so every time the shield gets equipped, their hp goes to 110hp could someone change it so that it adds a set amount of hp to the players CURRENT hp when it's equipped, and removes that set amount when unequipped. ill throw u like 200 robux if anyone could fix this this is just a segment of the whole script with the parts that need to be fixed:
function onKeyDown(key) vCharacter = Tool.Parent myHumanoid = vCharacter:FindFirstChild("Humanoid") if myHumanoid == nil then return end if key:lower() == "q" then if vCharacter:FindFirstChild("Shield") then print("Found Shield")
torso = vCharacter.Torso shieldWeld = torso:FindFirstChild("ShieldHolder") leftArm = vCharacter:FindFirstChild("Left Arm") if shieldWeld then shieldWeld.Parent = leftArm shieldWeld.Part0 = leftArm shieldWalkAnim = myHumanoid:LoadAnimation(Tool.ShieldWalk) shieldWalkAnim:Play()
shieldWeld.C1 = (shieldWeld.C1 + Vector3.new(0.0, 0.0, 0.5)) * CFrame.Angles(-math.pi/5, math.pi, math.pi/5) if Tool.ShieldActive then Tool.ShieldActive.Value = 1 end ratio = myHumanoid.Health/myHumanoid.MaxHealth print(ratio) myHumanoid.MaxHealth = 110 wait(0.2) myHumanoid.Health = myHumanoid.Health + (ratio * 10) else shieldWeld = leftArm:FindFirstChild("ShieldHolder") if shieldWeld then shieldWeld.Parent = torso shieldWeld.Part0 = torso shieldWeld.C1 = CFrame.new(Vector3.new(0, -0.7, 0)) * CFrame.Angles(math.pi/2, math.pi, 0) end if shieldWalkAnim then shieldWalkAnim:Stop() end if Tool.ShieldActive then Tool.ShieldActive.Value = 0 end if myHumanoid.MaxHealth > 100 then ratio = myHumanoid.Health/myHumanoid.MaxHealth myHumanoid.Health = ratio * 100 myHumanoid.MaxHealth = 100 end end end end end
function onEquippedLocal(mouse) vCharacter = Tool.Parent mouse.KeyDown:connect(onKeyDown) end
function onUnequippedLocal() if shieldWalkAnim then shieldWalkAnim:Stop() end if slashAnim then slashAnim:Stop() end if bashAnim then bashAnim:Stop() end
if Tool.ShieldActive then Tool.ShieldActive.Value = 0 end
if vCharacter then leftArm = vCharacter:FindFirstChild("Left Arm") if leftArm then shield = vCharacter:FindFirstChild("Shield") shieldWeld = leftArm:FindFirstChild("ShieldHolder") end myHumanoid = vCharacter:FindFirstChild("Humanoid") if myHumanoid then ratio = myHumanoid.Health/myHumanoid.MaxHealth myHumanoid.Health = ratio * 100 myHumanoid.MaxHealth = 100 end end if connection then connection:disconnect() end if shield then shield:Remove() end if shieldWeld then shieldWeld:Remove() end end
Tool.Equipped:connect(onEquippedLocal) Tool.Unequipped:connect(onUnequippedLocal) Tool.Activated:connect(onActivatedLocal) |
|
|
| Report Abuse |
|
|
Poomuffin
|
  |
| Joined: 13 Mar 2010 |
| Total Posts: 11369 |
|
| |
|
Grove537
|
  |
| Joined: 05 Feb 2010 |
| Total Posts: 3478 |
|
|
| 13 Oct 2013 05:34 PM |
just add in where the health part is: Humanoid.Health = Humanoid.Health + (Whatever value you want)
then just subtract it for the other part |
|
|
| Report Abuse |
|
|
Poomuffin
|
  |
| Joined: 13 Mar 2010 |
| Total Posts: 11369 |
|
|
| 13 Oct 2013 05:37 PM |
no but read the entire script its messed up |
|
|
| Report Abuse |
|
|
GGGGG14
|
  |
| Joined: 29 Jan 2012 |
| Total Posts: 25344 |
|
|
| 13 Oct 2013 05:38 PM |
| @poo if one part is broken, it can make the entire script malfunction/break |
|
|
| Report Abuse |
|
|
Grove537
|
  |
| Joined: 05 Feb 2010 |
| Total Posts: 3478 |
|
|
| 13 Oct 2013 05:40 PM |
| Honestly I don't want to read through your entire 200 line script. Sorry, but all you have to do is find the portion where it equips the shield and change the part where it changes the health to a set number and make it change it to the "humanoid.health + (Value of shield)" and then for the unequipped part just do the same thing but make it equal "humanoid.health - (Value of shield)" |
|
|
| Report Abuse |
|
|
Poomuffin
|
  |
| Joined: 13 Mar 2010 |
| Total Posts: 11369 |
|
|
| 13 Oct 2013 05:48 PM |
200 line 200 robux
1 robux per line!!!!!!!11!! good deal
but srsly ok thx ill try but i doubt it'll be that easy |
|
|
| Report Abuse |
|
|
Poomuffin
|
  |
| Joined: 13 Mar 2010 |
| Total Posts: 11369 |
|
|
| 17 Oct 2013 07:38 PM |
wont work any more help pls? |
|
|
| Report Abuse |
|
|
Poomuffin
|
  |
| Joined: 13 Mar 2010 |
| Total Posts: 11369 |
|
| |
|
|
| 17 Oct 2013 07:48 PM |
| Change Humanoid.MaxHealth = 110 to Humanoid.MaxHealth = Humanoid.MaxHealth + (insert set amount here) |
|
|
| Report Abuse |
|
|
Poomuffin
|
  |
| Joined: 13 Mar 2010 |
| Total Posts: 11369 |
|
|
| 17 Oct 2013 07:49 PM |
but what about the parts with like ratio and junk its confusing the heck out of me could you insert it in there |
|
|
| Report Abuse |
|
|
|
| 17 Oct 2013 07:51 PM |
| You didn't make this, did you? |
|
|
| Report Abuse |
|
|
Poomuffin
|
  |
| Joined: 13 Mar 2010 |
| Total Posts: 11369 |
|
| |
|
| |
|
Poomuffin
|
  |
| Joined: 13 Mar 2010 |
| Total Posts: 11369 |
|
|
| 17 Oct 2013 07:57 PM |
| not the slightest idea how to do something this complex |
|
|
| Report Abuse |
|
|
|
| 17 Oct 2013 07:57 PM |
| This isn't very advanced though. |
|
|
| Report Abuse |
|
|
| |
|
Poomuffin
|
  |
| Joined: 13 Mar 2010 |
| Total Posts: 11369 |
|
|
| 17 Oct 2013 08:03 PM |
well if i cant fix it and you cant fix it either
i sure think it's pretty advanced. |
|
|
| Report Abuse |
|
|