So, i made this confusing poorly script, and I have no idea why :WaitForChild()
isn’t finding Humanoid, and, why v
isn’t Frog.Value
Frog.value
is a string value who has the player name that will display they life at HealthGUI.
local hptext = script.Parent.LifePorcent
local Frog = game.ReplicatedStorage.GameVal.FrogName
local players = game.Players
local player
local character
function FindFrog()
for i, v in pairs(players:GetDescendants()) do
print(v)
if v.Name == Frog.Value then
print(v)
player = v
character = v.Character
repeat wait() until player.Character
local connection_health
local connection_max_health
end
end
end
function Update()
local humanoid = character:WaitForChild("Humanoid")
bar:TweenSize(UDim2.new(humanoid.Health / humanoid.MaxHealth, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, .5, true)
hptext.Text = humanoid.Health
end
function SetConnections()
local humanoid = character:WaitForChild("Humanoid")
connection_health = humanoid:GetPropertyChangedSignal("Health"):Connect(Update)
connection_max_health = humanoid:GetPropertyChangedSignal("MaxHealth"):Connect(Update)
Update()
end
local localplayer = game.Players.LocalPlayer
localplayer.CharacterAdded:Connect(function(char)
if player == Frog.Value then
character = char
if connection_health then connection_health:Disconnect() end
if connection_max_health then connection_max_health:Disconnect() end
SetConnections()
end
end)
SetConnections()