So, I'm doing a code that pushes all nearby players back away from the character, but whenever I do it, it does nothing. Any thoughts? I have a RemoteEvent in ReplicatedStorage as well named "push", and the serverscript is definitely running. Server Script:

ReplicatedStorage = game:GetService("ReplicatedStorage")

 remoteEvent = ReplicatedStorage:WaitForChild("push")

 function onCreatePart(orig, plr, char)
	local Players = game:GetService("Players")
	for i, player in pairs(Players:GetPlayers()) do
		if ((player.Character.HumanoidRootPart.Position - char.HumanoidRootPart.Position).magnitude <= 100) and (player.Name ~= plr.Name) then
			 local torso = player.Character.UpperTorso
			local back = Vector3.new(0,0,-100)
			 player.Character.HumanoidRootPart.Velocity = back
		end
	end            
end
remoteEvent.OnServerEvent:Connect(onCreatePart)

LocalScript:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local test = true
local remoteEvent = ReplicatedStorage:WaitForChild("push")
local player = game.Players.LocalPlayer
    local mouse = player:GetMouse()

mouse.KeyDown:connect(function(key)
    if test == true then
            if key == "x" and player.TeamColor == BrickColor.new("Mulberry") then
            local plr = player
            local char = player.Character
            remoteEvent:FireServer(plr, char)
            test = false
            wait(15)
            test = true
        end
        end
    end)

2 comments

0

I'm getting off and your question looked interesting so I'll quickly say that if you use PRINT statements in your code to test out that every line is working. Then you will eventually find which line your problem is on.

0

I just tried it and every print line script is running. There's no errors it's just not running.