NotPix
|
  |
| Joined: 27 Nov 2008 |
| Total Posts: 259 |
|
|
| 27 Dec 2013 09:09 AM |
Can someone explain to me, why this wont work?
repeat wait()until script.Parent:FindFirstChild("HealthGUI") repeat wait()until game.Players.LocalPlayer.Character player = game.Players.LocalPlayer char = player.Character repeat wait()until char.Humanoid human = char.Humanoid gui = script.Parent.HealthGUI
script.Sound:Play()
human.HealthChanged:connect(function() script.Sound.Volume = human.MaxHealth/human.Health end)
|
|
|
| Report Abuse |
|
|
Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
|
| 27 Dec 2013 09:15 AM |
| Is your script a LocalScript? |
|
|
| Report Abuse |
|
|
NotPix
|
  |
| Joined: 27 Nov 2008 |
| Total Posts: 259 |
|
| |
|
NotPix
|
  |
| Joined: 27 Nov 2008 |
| Total Posts: 259 |
|
|
| 27 Dec 2013 09:27 PM |
| and it is found in the startergui |
|
|
| Report Abuse |
|
|
NotPix
|
  |
| Joined: 27 Nov 2008 |
| Total Posts: 259 |
|
|
| 28 Dec 2013 12:31 PM |
| does anyone know how to fix this? |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 28 Dec 2013 12:34 PM |
| script.Sound.Volume = (human.Health / human.MaxHealth) * 100 |
|
|
| Report Abuse |
|
|
NotPix
|
  |
| Joined: 27 Nov 2008 |
| Total Posts: 259 |
|
|
| 28 Dec 2013 08:26 PM |
| Wait a minute now... Now how could i have it so its stops playing the sound after the humanoid health reaches 90 again? Also any idea on how to go about adjusting the pitch higher as your health gets lower? |
|
|
| Report Abuse |
|
|
NotPix
|
  |
| Joined: 27 Nov 2008 |
| Total Posts: 259 |
|
| |
|
| |
|
|
| 02 Jan 2014 07:52 PM |
Pro scripting. :)
local p = game:GetService('Players').LocalPlayer local h = p.Character.Humanoid
local cP = false local oH = h.Health
h.HealthChanged:connect(function(nH) if (nH < 90) nad (not cP) then script.Sound:Play() elseif (nH > 90) and (cP) then script.Sound:Stop() end end) |
|
|
| Report Abuse |
|
|
|
| 02 Jan 2014 07:52 PM |
Nevermind, near-completely failed. This is pro scripting. :)
local p = game:GetService('Players').LocalPlayer local h = p.Character.Humanoid
local cP = false
h.HealthChanged:connect(function(nH) if (nH < 90) nad (not cP) then script.Sound:Play() cP = true elseif (nH > 90) and (cP) then script.Sound:Stop() cp = false end end) |
|
|
| Report Abuse |
|
|
NotPix
|
  |
| Joined: 27 Nov 2008 |
| Total Posts: 259 |
|
|
| 10 Jan 2014 11:46 PM |
| it seems to break after it goes through once. hmm |
|
|
| Report Abuse |
|
|
|
| 14 Jan 2014 06:56 PM |
Yeah, "nad" instead of "and", as well as using the undefined variable "nH". Also, apologies for the wait.
local p = game:GetService('Players').LocalPlayer local h
if (not p.Character) then p.Character:wait() h = p.Character.Humanoid else h = p.Character.Humanoid end
local cP = false
if (h) then h.HealthChanged:connect(function(nH) local volume = h.MaxHealth / h.Health * 10
if (h.Health < 90) and (not cP) then script.Sound.Volume = volume script.Sound:Play() cP = true elseif (h.Health > 90) and (cP) then script.Sound:Stop() cp = false end end) |
|
|
| Report Abuse |
|
|
NotPix
|
  |
| Joined: 27 Nov 2008 |
| Total Posts: 259 |
|
| |
|
|
| 22 Jan 2014 07:52 AM |
Found yet another error...
local p = game:GetService('Players').LocalPlayer local h
if (not p.Character) then p.Character:wait() end
h = p.Character:FindFirstChild('Humanoid')
local cP = false
if (h) then h.HealthChanged:connect(function(nH) local volume = h.MaxHealth / h.Health * 10
if (h.Health < 90) and (not cP) then script.Sound.Volume = volume script.Sound:Play() cP = true elseif (h.Health > 90) and (cP) then script.Sound:Stop() cP = false end end) |
|
|
| Report Abuse |
|
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
| |
|