hello, im developing a game with downing system, in which the player is knocked down instead of dying. same as special fake-player bots, they also downing instead of death
problem: downed animations does not plays and proximity prompt to revive bot doesnot shows too, however everything works fine with players.
code:
local ch = script.Parent.Parent
local hum = ch.Humanoid
hum:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
local d = false
local anims = script.Parent.anims
local downed = hum:WaitForChild("Animator"):LoadAnimation(anims.fell)
local idled = hum:WaitForChild("Animator"):LoadAnimation(anims.idle)
local rs = game.ReplicatedStorage
local function setupInstances()
local pp = Instance.new("ProximityPrompt")
pp.HoldDuration = 5
pp.Enabled = false
pp.ActionText = "REVIVE"
pp.Parent = hum.RootPart
pp.Name = "revive_prompt"
local hl = Instance.new("Highlight")
hl.Parent = ch
hl.Adornee = ch
hl.OutlineColor = Color3.fromRGB(255,255,255)
hl.FillTransparency = 1
hl.FillColor = Color3.fromRGB(255,255,255)
hl.Enabled = false
hl.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
return pp, hl
end
local prompt, highlight = setupInstances()
local function ableToRevive()
prompt.Enabled = true
highlight.Enabled = true
end
function revived()
hum.RootPart.Anchored = false
prompt.Enabled = false
highlight.Enabled = false
idled:Stop()
downed:Stop()
hum.Health = hum.MaxHealth
d = false
ch.default_highlight.Enabled = true
end
function DOWNED()
if d then return end
d = true
print("DOWNED!")
ch.default_highlight.Enabled = false
hum.RootPart.Anchored = true
script.Parent["headshot-pitched"]:Play()
downed:Play()
task.wait(1)
idled:Play()
ableToRevive()
print("able to revive")
end
hum:GetPropertyChangedSignal("Health"):Connect(function()
if hum.Health <= 0 then
DOWNED()
end
end)
video:
example of PLAYER downing: