I’m working on a knockback system for when a player gets hit by a car. Im using Magnitude with Touched and it glitches out from time to time. If anyone has insight on a script that uses car knockback and or if you know some games that use character knockback from cars so I can contact the owner, please let me know.
part = script.Parent
local ragdoll = require(game:GetService("ServerScriptService").Main.Ragdoll)
local kb = require(game.ServerScriptService.Main.Knockback)
local db = {}
local knockback = script.Parent:GetAttribute("Knockback")
local speed = script.Parent:GetAttribute("MaxSpeedToDoDamage")
part.Touched:Connect(function(hit)
if table.find(db, hit.Parent) then return end
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum then
if part.AssemblyLinearVelocity.X > speed or part.AssemblyLinearVelocity.Y > speed or part.AssemblyLinearVelocity.Z > speed then
table.insert(db, hit.Parent)
script["Explosion Sound"]:Play()
kb.Start(hit.Parent, (hit.Parent.HumanoidRootPart.Position - part.Position).Unit * Vector3.new(200,0,200) + Vector3.new(0, 50), (script.Parent.Velocity - hit.Velocity).magnitude*knockback)
ragdoll.Start(hit.Parent)
task.wait(5)
table.remove(db, table.find(db, hit.Parent))
ragdoll.Stop(hit.Parent)
end
end
end)