#Knockback

1 messages · Page 1 of 1 (latest)

slender kraken
#

i am really struggeling with creating knockback or finding a way to add velocity to the player without them either getting faster in the air, flinging after the velocity, the velocity being way too weak. how or with which part can i create smooth and working knockback please help

dire ether
#

the easiest way would be to use bodyVelocity

slender kraken
balmy apexBOT
#

studio** You are now Level 1! **studio

dire ether
#
local bv = Instance.new("BodyVelocity")
bv.MaxForce, bv.Velocity = Vector3.new(5e4,5e2,5e4),plr.Character.HumanoidRootPart.CFrame.lookVector * 10
bv.Parent = hit.Parent.HumanoidRootPart
game.Debris:AddItem(bv,0.16)
#

this worked fine for me

orchid stream
#

like you fly when you hit a wall

slender kraken
#

alright ima try but what are the numbers in the vector3.new? 5e4 5e2?

orchid stream
#

ig

dire ether
#

scientific notation

#

bv.MaxForce = Vector3.new(50000, 500, 50000)

orchid stream
dire ether
#

basically this

dire ether
#

im just saying this the easiest way

orchid stream
#

body velocity is depreciated

orchid stream
dire ether
#

if u got time u should learn linear velocity

#

defo be useful

orchid stream
dire ether
#

i mean it really isnt complicated

#

its almost the same thing

orchid stream
dire ether
#

@slender kraken

orchid stream
#

and attachements confused me at first but now, its good

dire ether
#
-- you need to define the player first
local HRP = player.Character.HumanoidRootPart

local Part = Instance.new("Part", workspace) -- the part to move
Part.CFrame = HRP.CFrame * CFrame.new(0,0,-3) -- Putting the part infront of the player

local Attachment = Instance.new("Attachment", Part) -- the attachment used in Linearvelocity

local LV = Instance.new("LinearVelocity", Attachment) -- creating the linear velocity
LV.MaxForce = math.huge -- no need to worry about this
LV.VectorVelocity = HRP.CFrame.lookVector * 100 -- change 100 with how fast you want the projectile to go
LV.Attachment0 = Attachment -- setting the attachment

game.Debris:AddItem(Part, 2) -- deletes the moving part after 2 second
orchid stream
#

you need to do some maths

slender kraken
#

how can i prevent the player from flinging?

#

because i currently use linearvelocity but it flings

orchid stream
#

its easy

#

local ROLL_DURATION = 0.2
local ROLL_FORCE = 100
local ROLL_COOLDOWN = 5

local Roll = {}

function Roll.Start(plr : Player, track : AnimationTrack, sound : Sound    )
    
    if not canRoll then return end
    canRoll = false
    
    task.delay(ROLL_COOLDOWN, function()
        canRoll = true
    end)
    
    local char = plr.Character or plr.CharacterAdded:Wait()
    local Humanoid = char:WaitForChild("Humanoid")
    local hrp : BasePart = char:WaitForChild("HumanoidRootPart")
    

    local attachment = Instance.new("Attachment")
    attachment.Parent = hrp
    
    local linearVelocity = Instance.new("LinearVelocity")
    linearVelocity.Attachment0 = attachment :: Attachment
    linearVelocity.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
    linearVelocity.MaxForce = 1500 * hrp.AssemblyMass
    linearVelocity.VectorVelocity = Vector3.new(0, 0, - ROLL_FORCE)
    linearVelocity.Parent = hrp

    local sound = sound:Clone()
    sound.Parent = hrp
    
    track:Play()
    sound:Play()
    
    
    game.Debris:AddItem(linearVelocity, ROLL_DURATION)
    game.Debris:AddItem(sound, ROLL_DURATION)
    

end
return Roll ```