server script:
local remote = game.ReplicatedStorage:WaitForChild("Hitted1")
remote.OnServerEvent:Connect(function(plr, target, mouseCFrame)
if plr then
if plr.Parent:FindFirstChild("Humanoid") then
local lookVector = mouseCFrame.LookVector --Gets mouse CFrame
if mouseCFrame.LookVector.Y < 0 then
lookVector = mouseCFrame.LookVector * Vector3.new(1,-1,1) --This is only to make player knockback upwards, and not downwards. You can remove this if you want.
end
local root = plr.Parent.HumanoidRootPart
local velocity = Instance.new("BodyVelocity")
local humanoid = plr.Character:WaitForChild("Humanoid")
velocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
velocity.P = 1500
velocity.Velocity = lookVector * 5 * Vector3.new(5, 5, 5) --Get mouse direction and increases it, you can mess around with this values until you find a good one
velocity.Parent = root
wait(0.5)
velocity:Destroy()
end
end
end)
local script:
local tool = script.Parent
local remote = game.ReplicatedStorage:WaitForChild("Hitted1")
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
tool.Activated:Connect(function()
remote:FireServer(mouse.Target, mouse.Hit)
end)
this script above works last time now it’s not working and no errors
it’s supposed to knockback the player after hit with the tool
any help will work and post with the script