It works fine but i’d just like some feedback on possible bad practices:
REMOVED
It works fine but i’d just like some feedback on possible bad practices:
REMOVED
Everything looks good here, but it is common that when scripting and you have variables and functions, to have their name spelt with the first word lower cases like this: onDeathReset, or hungerValue. But i’m just nitpicking at that point.
Well you come in handy as you post this comment.
I was just testing a script similar to this one and it’s giving me some problems?
I’ll give you details if you want to help me out
sure, hit me (need to add 30 more characters)
local function BloodFunc()
local health = humanoid.Health
if health >= 75 then
BloodFrame.StateLabel.Text = StatesModule.BloodState1
StatesFrame.Parent.HintStateBlood.Text = StatesModule.BloodHint1
elseif health >= 50 and health < 75 then
BloodFrame.StateLabel.Text = StatesModule.BloodState2
StatesFrame.Parent.HintStateBlood.Text = StatesModule.BloodHint2
elseif health >= 25 and health < 50 then
BloodFrame.StateLabel.Text = StatesModule.BloodState3
StatesFrame.Parent.HintStateBlood.Text = StatesModule.BloodHint3
elseif health > 0 and health <= 25 then
BloodFrame.StateLabel.Text = StatesModule.BloodState4
StatesFrame.Parent.HintStateBlood.Text = StatesModule.BloodHint4
end
humanoid.Died:Connect(function()
print(health)
OnDeathReset()
end)
end
humanoid.HealthChanged:Connect(BloodFunc)
You see, same script as before, only with Humanoid.Health instead of a Value.
Take a look at the last lines.
humanoid.Died:Connect(function()
print(health)
OnDeathReset()
Basically makes a function on the same script run when the Humanoid.Died is fired.
This function is only ran the first time the player dies, but for the second time, humanoid.Died just doesn’t fire. Do you know why?
in your script, put
print(humanoid)
then die two times and see what the result is. you should get “humanoid” both times
Exactly where in the script? The “health” print I sent earlier already works but only first time. It prints the health wich is 0 at the time humanoid.Died fires, but when trying again it doesn’t print the health.
Edit:
I made this
humanoid.Died:Connect(function()
print(humanoid)
OnDeathReset()
end)
Same result, only prints the first time but that’s because the humanoid.Died doesn’t fire the second time, why the hell doesn’t it fire??
I’ll look around the files, there might be something interfering with this code
print it right under local heath = humanoid.health
Isn’t working, I think I found the problem in the defined variables, it’s a problem with the humanoid, possibly the same one that we solved in the other post
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character.Humanoid
print (found)
it only prints found the first time
Maybe I should use:
player.CharacterAdded:Connect(function(character)
Humanoid = character.Humanoid
end)
Like with the other post?
Edit: It’s working now.
try that, see what happens asdfasfas
Yup that worked thanks for the help anyways
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.