-
What do you want to achieve? I want the push players ability to be nice and smooth without any delays
-
What is the issue? So I have a push players tool that works with a remote event, client to server. I want the ability to work smooth without that small delay at the start. Here’s a video of how it’s working at the moment: Push Players
-
What solutions have you tried so far? I looked at some DevForum posts and they were all using BodyVelocity. I know that BodyVelocity is deprecated so I would need to use something else instead… But I don’t know what to use cause I want the player to be able to push the other player the same way the player is facing towards.
sorry i gave you brain cancer reading this lmao
Client:
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
print('1')
Character.ChildAdded:Connect(function(Tool)
print('2')
if Tool:IsA("Tool") then
print('3')
Tool.Activated:Connect(function()
print('4')
local Force = Tool:GetAttribute("Force")
local Head = Character:FindFirstChild("Head")
local Mouse = LocalPlayer:GetMouse()
local MouseTarget = Mouse.Target or nil
if MouseTarget ~= nil then
print('5')
local HumanoidRootPart = MouseTarget.Parent:FindFirstChild("HumanoidRootPart") or MouseTarget:FindFirstChild("HumanoidRootPart")
if HumanoidRootPart then
if MouseTarget ~= Character:WaitForChild("HumanoidRootPart") then
script:WaitForChild("Push"):FireServer(HumanoidRootPart, Head, Force)
end
end
end
end)
end
end)
Server:
local Debris = game:GetService("Debris")
script.Parent:WaitForChild("Push").OnServerEvent:Connect(function(Player, HumanoidRootPart, Head, Force)
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Parent = HumanoidRootPart
BodyVelocity.Velocity = Head.CFrame.LookVector * (8 + Force)
BodyVelocity.MaxForce = Vector3.new(30000, 0, 30000)
Debris:AddItem(BodyVelocity, .5)
end)