I currently have a vest system and it should be setting the health when a player has a vest but for some reason, it just won't work at all it works perfectly fine without doing that but while doing it it won't work at all what is going on?
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAppearanceLoaded:Connect(function(Character)
local Humanoid = Character:WaitForChild("Humanoid")
---PlayerHealth
local MaxHealth = Humanoid.MaxHealth
local Health = Humanoid.Health
---Vests
local Vests = {
["TanVest"] = Character:FindFirstChild("TanVest");
["BlackVest"] = Character:FindFirstChild("BlackVest");
}
---VestLocator
local charChildren = Character:GetChildren()
local tanVest = table.find(charChildren, Vests.TanVest)
local blackVest = table.find(charChildren, Vests.BlackVest)
if tanVest then --This without the math works fine but with the math wont, same fo the elseif
Health = 150
MaxHealth = 150
print("Player has a TanVest")
elseif blackVest then
print("Player has a BlackVest")
Health = 200
MaxHealth = 200
else
print("Player has no vest")
end
end)
end)

6 comments
did you look in the output? no errors?
None
maybe it doesnt trigger it for some reason? ive had the exact same problem some times, but ive noticed it only happened with LocalScripts. are you using a LocalScript? if so, you could probably benefit from using RemoteEvent:OnServerInvoke for that player.
I'm using a normal script
well, then, maybe you could use the reverse?: remoteEvent:OnClientEvent:connect() and in the ServerScript: remoteEvent:FireClient()
I actually tried that as a solution and it never did set the health and if I tried to do something like that for the if and elseif it wouldn't work like at all no text would be printed stating the vest a player has on