Could someone help me with a script that would basically increase an NPC’s walkspeed the lesser % health they have
Could someone help me with a script that would basically increase an NPC’s walkspeed the lesser % health they have
Simple script to increase walkspeed as health depletes. You can experiment around with the algorithm to suit your game
local npc = script.Parent -- Server script in npc
local hum = npc.Humanoid
hum:GetPropertyChangedSignal('Health'):Connect(function()
if hum.Health <= 0 then return end -- Doing this to prevent zero division error
hum.WalkSpeed = 16 / (hum.Health/hum.MaxHealth)
end)
Thanks!
One question, do I adjust the hum.Walkspeed = 16 value with the NPC’s current walkspeed value?
he set it to 16 as it is the default speed, you can edit the 16 to higher or lower but the script would still work the same.
Alright
thirtycharacters needed
For
You can change it to this so it adjusts to whatever walkspeed they have
hum.WalkSpeed /= (hum.Health/hum.MaxHealth)`
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.