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)
Well, for a damage script: EXAMPLE
local LavaBox = script.Parent local DamageAmount = 10 -- you can change that local function DealDamage(part) local hum = part.Parent:FindFirstChild("Humanoid) if hum then hum.Health - DamageAmount end end LavaBox.Touched:Connect(DealDamage)
and for fling, try this
Player.pos = (0, 5000, 0) -- can be changed