-- PushClient (LocalScript inside Tool)
local tool = script.Parent
local player = game.Players.LocalPlayer
local debounce = false
tool.Activated:Connect(function()
if debounce then return end
debounce = true
local mouse = player:GetMouse()
local targetPos = mouse.Hit.Position
-- Fire to server
game.ReplicatedStorage:WaitForChild("PushEvent"):FireServer(targetPos)
wait(0.5) -- cooldown
debounce = false
end)
📡 RemoteEvent (for communication)
Go to ReplicatedStorage.
Right-click → Insert Object → choose RemoteEvent.
Rename it to PushEvent.
📜 Server Script (Put in Tool → name: PushServer)
lua
-- PushServer (Script inside Tool)
local tool = script.Parent
local PUSH_FORCE = 50
local PUSH_RADIUS = 5
local remoteEvent = game.ReplicatedStorage:WaitForChild("PushEvent")
remoteEvent.OnServerEvent:Connect(function(player, targetPos)
local character = player.Character
if not character or not character:FindFirstChild("HumanoidRootPart") then return end
local hrp = character:FindFirstChild("HumanoidRootPart")
-- Find nearby players to push
for _, otherPlayer in pairs(game.Players:GetPlayers()) do
if otherPlayer ~= player and otherPlayer.Character and otherPlayer.Character:FindFirstChild("HumanoidRootPart") then
local otherHRP = otherPlayer.Character.HumanoidRootPart
local distance = (otherHRP.Position - hrp.Position).Magnitude
if distance <= PUSH_RADIUS then
local direction = (otherHRP.Position - hrp.Position).Unit
otherHRP.Velocity = direction * PUSH_FORCE
end
end
end
end)
✅ You're Done!
When a player equips the tool and clicks, it sends a request to push any nearby players away from themselves, using physics-based velocity!
🧪 Test It
Playtest with 2+ players (use "Start Server" and add clients via the Test tab).