im new to scripting is there a way to detect if the enemy health is lower than 100
i tried other Operators it just dont work.
script:
script.Parent.OnServerEvent:Connect(function(plr)
local player = plr.Character
local box = game.ReplicatedStorage.Hitbox:Clone()
local weld = Instance.new("Weld")
local bound = 1
box.Parent = player.HumanoidRootPart
weld.Parent = player.HumanoidRootPart
weld.Part0 = plr.Character.HumanoidRootPart
weld.Part1 = plr.Character.HumanoidRootPart.Hitbox
box.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Humanoid.Health <= 100 and bound == 1 then
print("alive")
bound = 2
local speed = hit.Parent.Humanoid
speed:TakeDamage(5)
elseif hit.Parent.Humanoid.Health == 25 and bound == 1 then
print("Dead")
bound = 2
local speed = hit.Parent.Humanoid
speed:TakeDamage(100)
end
end
end)
wait(0.5)
bound = 1
box:Destroy()
weld:Destroy()
end)
box.Touched:Connect(function(hit)
print(hit.Parent) -- to see if the hitbox works and what did you hit
if hit.Parent:FindFirstChild("Humanoid") then
print(hit.Parent.Humanoid.Health) -- to see its health
if hit.Parent.Humanoid.Health <= 100 and bound == 1 then
...
Yeah print statement checks health as well but then he will have a bug of the elseif statement not running because he should swap the elseif line of code with the first if statement line