I made a script that launches a player into the air when they get damaged. The problem is that it happens when the player is healed too. I have tried things like "if humanoid.Health < Health" but they all didn't work. It'd be great if someone helped me. The script is inserted inside the character model.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
p = ReplicatedStorage:FindFirstChild("YellowPoof")
local tweeninfo = TweenInfo.new(0.85)
local ts = game:GetService("TweenService")
local goal = {}
goal.Size = Vector3.new(11, 11, 11)
goal.Transparency = 1
db = true
function onHurt()
if db == true then
db = false
local humanoid = script.Parent.Humanoid
local p2 = p:Clone()
local tween = ts:Create(p2, tweeninfo, goal)
p2.Parent = workspace
p2.Position = humanoid.Parent.HumanoidRootPart.Position
tween:Play()
if humanoid.RigType == Enum.HumanoidRigType.R15 then
local animation = humanoid:LoadAnimation(script.Animation)
animation:Play()
elseif humanoid.RigType == Enum.HumanoidRigType.R6 then
local animation = humanoid:LoadAnimation(script.Animation2)
animation:Play()
end
humanoid.Jump = true
humanoid.WalkSpeed = 10
wait(1.85)
humanoid.WalkSpeed = 19.5
p2:Destroy()
db = true
end
end
script.Parent.Humanoid.HealthChanged:Connect(onHurt)

1 comment
I already know how to make parts damage players. What I want to know is how to trigger a script inside a character when the player is damaged