[SOLVED] Why does my character not heal more than once?
Asked by
3 years ago Edited 3 years ago
So, I am making a simple game about collecting apples to heal yourself, you need to collect enough apples in order to not die. You take x amount of damage per second.
And the problem is that when I collect an apple the first time everything goes as planned and I get healed, but the second time I collect an apple I do not heal. I have not seen anyone else get the same issue and was wondering how to fix this. I also do not get any errors in the output.
Part of a script that tells a value to get updated to 20
1 | game.ReplicatedStorage.heal.Value = 20 |
LocalScript that handles the new value and updates your health
1 | local humanoid = game.Players.LocalPlayer.Character.Humanoid |
2 | local heal = game:GetService( "ReplicatedStorage" ):WaitForChild( "heal" ) |
4 | humanoid.Health = humanoid.Health + game.ReplicatedStorage.heal.Value |
5 | if heal.Value > = 1 then heal.Value = 0 end |
oh i probably should've mentioned that you collect the apples by touching them, not clicking and the script that tells the localscript to heal you is in the apple
UPDATE : Ok so i found that the local script that handles the new value doesnt see that the value has changed the second time i grab an apple. Does anyone know why this is happening?
Log:
1 | 14 : 11 : 56.573 applePickupScript thinks that heal.Value = 20 - Server |
2 | 14 : 11 : 56.574 Script says that actall value is 20 - Server - Script: 2 |
3 | 14 : 11 : 56.591 LocalScript thinks that heal.Value = 0 - Client - LocalScript: 6 |
Check out this post for the soultion to my problem https://scriptinghelpers.org/questions/123520/solved-why-does-my-localscript-not-see-that-ive-changed-a-value