Hi! I’m new to the forums so sorry if I do something wrong.
So I’m making a game which has Minecraft combat but I’m really new to coding. I already have click to hurt a player (Model but i wanna add a knockback feature. Anybody have any idea how?
make the person go back if they are hit maybe with like bodymovers bodyforce bodyvelocity or cframe, i dont really know
belongs in #help-and-feedback:scripting-support
I’m gonna be honest I have no clue what that is I’m a complete noob.
Umm Try changing the velocity of the Humanoid Root Part and apply ragdoll to the player?
Well I don’t want ragdoll tho I want like a small push
But I get what u mean I’ll try
I mean have a bodyvelocity in the players humanoidrootpart, and upon clicking the player add a force on the bodyvel in the lookdirection of the player that hit the other player?
Well body velocity is almost not physically based.Like the player can fly if the force stayed for long
Try use CFrame.LookVector of the punching player if your game is First person.Then Find the HumanoidRootPart in the player and then put
.Velocity = --here insert force direction
into the Humanoid Root part.
Well if you need a understanding of what LookVector is here it is:
LookVector is basically the Vector (Direction) The Part’s Front Surface is facing. If we change this to a negative value. It will be behind the Part. So you could do
workspace.BV.Velocity = (HumanoidRootPart.CFrame.-LookVector * --Multiplier--)
So something like ```
workspace.BV.Velocity = (HumanoidRootPart.CFrame.-LookVector * 5)
Yes, and so it will move backwards
local Dead = false
local Position = CFrame.new(0,105,0)
local SpawnSamePos = false
local Humanoid
while not Humanoid do
wait()
Humanoid = script.Parent:FindFirstChildWhichIsA("Humanoid")
end
function Died()
Dead = true
wait(0.6)
local Player = game.Players:GetPlayerFromCharacter(Humanoid.Parent)
if Player then
script.Parent = game.Workspace
delay(1,function()
script.Parent = nil
end)
Player:LoadCharacter()
if SpawnSamePos then
Player.Character:FindFirstChild("Head").CFrame = Position
end
end
end
function Fling()
if Humanoid and Humanoid.Parent then
for i = 1,16 do
local C = Humanoid.Parent:GetDescendants()
if Humanoid.Parent:IsA("Model") then
for i = 1,#C do
if C[i]:IsA("BasePart") and not C[i].Parent:IsA("Tool") then
C[i].Anchored = false
end
end
local Additional = Vector3.new()
if Humanoid.Parent:FindFirstChild("Head") then
Additional = Humanoid.Parent.Head.CFrame.lookVector * -1
end
Humanoid.Parent:TranslateBy(Vector3.new(0,3.5 - i / 2.5,0) + Vector3.new(Additional.X,Additional.Y,Additional.Z))
end
wait(0.01)
end
end
end
Humanoid.HealthChanged:connect(Fling)
while true do
wait(0.01)
if Humanoid and Humanoid.Parent:FindFirstChild("Head") then
Position = Humanoid.Parent.Head.CFrame
SpawnSamePos = true
else
Position = CFrame.new(0,105,0)
SpawnSamePos = false
end
end
So i have that, but now whenever I regenerate I get pushed back, how do I fix this?