Im making minigames game and I would like to make minigame where players try to deal knockback to each others so other players would fall off the platform. And last one standing wins. But I dont know how to add Knockback for tool. Is it even possible? If yes, how?
This code won't be the best but it should just about work. It doesn't always throw the player or object but it does most of the time. How hard it's hit also affects the knockback given.
local knockbackPart = script.Parent -- When it's hit, it creates knockback on what hit it local knockbackMultiplier = 10 -- How strong the knockback is local knockbackDuration = .5 -- How long in seconds the knockback lasts knockbackPart.Touched:Connect(function(part) local force = knockbackPart.Position * knockbackMultiplier local bodyForce = Instance.new("BodyForce", part) bodyForce.Force = force wait(knockbackDuration) bodyForce:Destroy() end)
Hey look ik this was back in 2019 But here:
-- // Knock Back System \\ local Fist = script.Parent -- // [Fist] Is A Tool local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local function Fist_Swung() local HumanoidRootPart = Mouse.Target:FindFirstChild("HumanoidRootPart") local KnockBack = Vector3.new(5, 5, 5) if HumanoidRootPart then local KnockBackActivate = HumanoidRootPart.Position * KnockBack HumanoidRootPart.Position = KnockBackActivated end return KnockBackActivate end Tool.Activated:Connect(Fist_Swung)