What do you want to achieve? Keep it simple and clear!
I want to make a custom bomb that knockbacks humanoids
What is the issue? Include screenshots / videos if possible!
The knockback aint knocking back and i want to know why
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have, just found things about direction
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local ball=script.Parent
task.wait(2)
ball.Anchored=true
ball.CanCollide=false
for count = 1,10 do
ball.Size=Vector3.one*1.25
task.wait(0.5/count)
ball.Size=Vector3.one*2
task.wait(0.5/count)
end
ball.Size=Vector3.one*10
ball.Touched:Connect(function(hit)
assert(hit.Parent:FindFirstChild('Humanoid') or hit:FindFirstChild('Humanoid'),'hehee')
local direction : Vector3 = -(ball.Position - hit.Parent.PrimaryPart.Position).Unit
hit.Parent.Humanoid:TakeDamage(3)
print(hit.Parent)
hit.Parent.HumanoidRootPart:ApplyImpulse(direction*1000)
end)
task.wait(0.3)
ball:Destroy()
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
Any errors in your output window?
Have you tried increasing the impulse Force? How about making the force upwards slightly to get past any friction between the player and the floor.
Put prints in your script to find out what’s working and if it’s getting stuck and why.
Something like after the ball.Touched function put something like print(hit) to see what it hit.
Also I know I’ve seen a lot of posts about knockbacks from punches or spells. Have you tried different search wording? I just searched ‘knockback’ and found quite a few posts about that, but maybe try ‘pushback’ or ‘push player’.
hey there! I know that everything works except for the applyimpulse part! even if I set it to absurd numbers nothing happens. it is like the applyimpulse isnt there. When I do the apply impulse command in the command bar while the game is running , it works, but in the script it doesnt
Its hard to get a character to move with realistic physics just because of the humanoid being a pain. There are a few humanoid states (like sitting, platform standing, etc) that enable physics on the character to be more accurate so I recommend looking into that.
As for ApplyImpulse I have no clue why that wouldn’t work, so I experiment with other options.
that would be strange as the documentation for apply impulse says:" If the part is owned by the server, this function must be called on a server Script. If the part is owned by a client, this function can be called on a LocalScript or server Script." and i was using a server script.