Hi. I wanted to make a boss fight that will give you a badge for killing the boss, but unluckily I can’t take damage to the boss (Idk why), and also when I change boss’s HP to a little bit smaller, the screen that shows his HP isn’t updating.
Main script:
local plr = game:GetService("Players")
local debris = game:GetService("Debris")
local rs = game:GetService("ReplicatedStorage")
local ts = game:GetService("TweenService")
local pfs = game:GetService("PathfindingService")
local char = script.Parent
local primary = char.PrimaryPart
local human = char:WaitForChild("Humanoid")
local tag = char.Head:WaitForChild("Tag")
local debounce = false
local value = 0
local skill = nil
local previousskillenabled = false
local path = pfs:CreatePath()
local properties = {
Size = Vector3.new(0.05,15,15),
Transparency = 1
}
local jumpgoal = {
Size = Vector3.new(8, 4, 8),
Transparency = 1
}
local diedgoal = {
Size = Vector3.new(0.25,0.25,0.125),
Transparency = 1
}
local trashgoal = {
Transparency = 0
}
local info = TweenInfo.new(0.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut)
local info2 = TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut)
if not tag then return end
tag.Health.Text = human.Health.."/"..human.MaxHealth
human.HealthChanged:Connect(function()
script.Parent:WaitForChild("Head"):WaitForChild("Tag"):WaitForChild("Health").Text = "Health: "..human.Health.." / "..human.MaxHealth.."."
if human.Health <= 0 then
end
end)
local larm = script.Parent:FindFirstChild("HumanoidRootPart")
local rarm = script.Parent:FindFirstChild("HumanoidRootPart")
function findNearestTorso(pos)
local list = game.Workspace:children()
local torso = nil
local dist = 10000
local temp = nil
local human = nil
local temp2 = nil
for x = 1, #list do
temp2 = list[x]
if (temp2.className == "Model") and (temp2 ~= script.Parent) then
if plr:GetPlayerFromCharacter(temp2) then
temp = temp2:findFirstChild("HumanoidRootPart")
human = temp2:findFirstChild("Humanoid")
if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
if (temp.Position - pos).magnitude < dist then
torso = temp
dist = (temp.Position - pos).magnitude
end
end
end
end
end
return torso
end
primary.Touched:Connect(function(hit)
local hitchar = hit.Parent
if human.Health <= 0 or not hitchar then return end
if hitchar:IsA("Model") then
if not plr:GetPlayerFromCharacter(hitchar) then return end
local hithuman = hitchar:FindFirstChild("Humanoid")
if hithuman then
if debounce then return end
debounce = true
hithuman:TakeDamage(25)
wait(.5)
debounce = false
end
end
end)
function highjump(target)
human:MoveTo(target.Position)
human.Jump = true
local bodyv = Instance.new("BodyVelocity",primary)
bodyv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bodyv.Velocity = Vector3.new(0,100,0)
debris:AddItem(bodyv,.15)
end
function forcefield()
local ff = Instance.new("ForceField",char)
debris:AddItem(ff,5)
end
while wait() do
if human.Health <= 0 then return end
local target = findNearestTorso(primary.Position)
if target ~= nil then
value = value + 1
if value >= 1 then
value = 0
end
path:ComputeAsync(primary.Position,target.Position)
local waypoints = path:GetWaypoints()
for i, waypoint in ipairs(waypoints) do
if waypoint.Action == Enum.PathWaypointAction.Jump then
human.Jump = true
end
human:MoveTo(waypoint.Position)
human.MoveToFinished:Wait()
end
end
end
I can’t take any damage with a gun and by changing his HP the screen that shows his current HP (current HP / max HP) isn’t updating, but it should to.
It’s my first time trying to edit NPC’s scripts (I took it from toolbox)
Alr, if no one wants to answer, I’ll just re-write the code
lmk if you made it, otherwise send me the script afterwards
the game:GetService… thingy makes the whole thing loop infinitely
But how can I use it on the boss? I mean the heartbeat thing.
The entire line i said above runs your function idefinitly, heartbeat means: every time the game updates (0.005-~0.009 seconds)
But still, how can I use it on NPCs?
Lemme show u a script real quick, be right back
how do i make that scripting quote tho?
Idk what do you mean bro, you can just send it.
it will just be a mess if i send it like that
here it is, i left some comments so you know what i wrote :)*
hope it helped!