So.. I'm making a Knock back script when a player is hit. It works completely fine, except for when the Player who was knock backed is being 'Tweened' on the Y-Axis, it is very choppy and glitchy. I believe this is because of the fact that Gravity isn't being ignored, so the player is wanting to be pulled down. I could just make Gravity 0 for that player, then bring it back once the tween is finished, but that just seems like not the best way to script it. Here is the code for the Normal Tween without BodyVelocity. `` hitbox.Touched:Connect(function(hit) if hit:IsA("BasePart") then if not hit:IsDescendantOf(character) then --Prevents Self Damage local enemyHumanoid = hit.Parent:FindFirstChild("Humanoid") local enemyHumRootPart = hit.Parent:FindFirstChild("HumanoidRootPart") if enemyHumanoid and enemyHumRootPart then
local hitSFX = Instance.new("Sound") hitSFX.SoundId = "rbxassetid://7346577489" hitSFX.PlayOnRemove = true hitSFX.Parent = hitbox hitSFX:Destroy() hitbox:Destroy() enemyHumanoid:TakeDamage(damage) local react = enemyHumanoid:LoadAnimation(enemyAnimsTable[count]) react:Play() if count == 4 then local goal = {} goal.CFrame = CFrame.new((humRootPart.CFrame * CFrame.new(0,5,-15)), humRootPart.CFrame.p) local info = TweenInfo.new(0.5) local tween = tweenService:Create(enemyHumRootPart,info,goal) tween:Play() end end end end end)
I've been told countless times to use BodyVelocity, but when I use Vector3 in the Tween, it takes the player that was Knock backed and puts them to a certain Coordinate.. It knocks them back super far as well. This is the code for when I used BodyVelocity.
`` hitbox.Touched:Connect(function(hit) if hit:IsA("BasePart") then if not hit:IsDescendantOf(character) then --Prevents Self Damage local enemyHumanoid = hit.Parent:FindFirstChild("Humanoid") local enemyHumRootPart = hit.Parent:FindFirstChild("HumanoidRootPart") if enemyHumanoid and enemyHumRootPart then
local hitSFX = Instance.new("Sound") hitSFX.SoundId = "rbxassetid://7346577489" hitSFX.PlayOnRemove = true hitSFX.Parent = hitbox hitSFX:Destroy() hitbox:Destroy() enemyHumanoid:TakeDamage(damage) local react = enemyHumanoid:LoadAnimation(enemyAnimsTable[count]) react:Play() if count == 4 then local bv = Instance.new("BodyVelocity") bv.Parent = enemyHumRootPart bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge) bv.P = 0.5 bv.Velocity = Vector3.new(0,5,-15) debris:AddItem(bv, 0.1) local goal = {} goal.CFrame = CFrame.new((humRootPart.CFrame * bv.Velocity), humRootPart.CFrame.p) local info = TweenInfo.new(0.5) local tween = tweenService:Create(enemyHumRootPart,info,goal) tween:Play() end end end end end)
My goal is to make the player Move Back 15 Studs when hit, and up 5. It worked perfect when I did it just on the Z-Axis. But the Y-Axis just messes it all up! Thanks for your help!