This may be irrelevant to your issue but I noticed the way you are making the text “fade out”, I would rather recommend using tween service for that as you can easily choose exactly how long the “fade out” is going to take, and you can tween a bunch of various properties at the same time. You can also cancel currently running tweens with new ones, so it will not overlap.
I’ve noticed recently that developers have had some kind of obsession over containing respawn logic in Player.Added Character.Added throwaway scopes, yet poor old StarterCharacterScripts is getting ignored for code to get added on spawn.
What you could do is put this as a script in StarterCharacterScripts and truncate any bit related to PlayerAdded and CharacterAdded. After that, create your own health regen logic and call this script Health. It’ll overwrite the default Health script and it seems like a better alternative. You also won’t have any repeated firing of HealthChanged.
That wouldn’t really change anything and would actually make the coding convention worse, not better.
HealthChanged is like GetPropertyChangedSignal, except more appropriate for checking when health changes and the new health of the humanoid is important to know.
If HealthChanged fires twice, so would GetPropertyChangedSignal.
That’s actually a really good point although, I’d have to use a LocalScript wouldn’t I? I’m using a ModuleScript for this (because I wanna try using as little Scripts and LocalScripts as possible)
ModuleScripts take the environment of the script they’re called in. If it’s called within a LocalScript, the module will send a bytecode that’s only available to the client – and vice versa.
So it wouldn’t really matter whether or not you should switch from a ModuleScript (running on the server) to a LocalScript. You can still make use of modules, just make sure the module knows who the player is.
Module:
return function(player) -- uses function currying which "makes" the module a function. allows it to take in custom arguments upon require()'ing
local mymodule = {}
local methods = setmetatable({}, {
__index = mymodule
})
function mymodule.new()
local o = setmetatable({
myplayer = player
}, {
__index = methods
})
return o
end
function methods:whoismyplayer()
print(self.myplayer)
end
return mymodule
end
LocalScript:
local mymodule = require(script.ModuleScript)(game.Players.LocalPlayer) -- localplayer arg
local myplayer = mymodule.new()
myplayer:whoismyplayer() -- output: NinjoOnline