So I'm making a code when you press x it makes the other players nearby physics mode fall, I'm standing right next to the player but it isn't working, or printing anything. Hi isn't printing. Any thoughts?
This is the local script.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local test = true
local remoteEvent = ReplicatedStorage:WaitForChild("push")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local ragDolled = false
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(char)
test = false
wait(15)
test = true
end
end
end)
This is the ServerScript. Hi isn't printing.
ReplicatedStorage = game:GetService("ReplicatedStorage")
remoteEvent = ReplicatedStorage:WaitForChild("push")
remoteEvent2 = ReplicatedStorage:WaitForChild("push2")
function onCreatePart(orig, char)
local Players = game:GetService("Players")
for i, player in pairs(Players:GetPlayers()) do
if ((player:DistanceFromCharacter(char.HumanoidRootPart.Position) <= 200) and (player.Name ~= orig.Name)) then
print("hi")
remoteEvent2:FireClient(player)
end
end
remoteEvent.OnServerEvent:Connect(onCreatePart)
This is the second local script for the FireClient. Hi isn't printing here either.
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local welcomePlayerEvent = ReplicatedStorage:WaitForChild("push2")
local function onWelcomePlayerFired()
print("hi")
player.Character.PlayerHit.Character.Humnaoid:ChangeState(Enum.HumanoidStateType.Physics)
player.character.Humanoid.WalkSpeed = 0
player.character.Humanoid.JumpPower = 0
local humanoid = player.character.humanoid
local setEnabled = humanoid:GetState() ~= Enum.HumanoidStateType.Physics
humanoid:ChangeState(setEnabled and Enum.HumanoidStateType.Physics or Enum.HumanoidStateType.GettingUp)
player.character.Animate.Disabled = setEnabled
if setEnabled then
for _,v in pairs(humanoid:GetPlayingAnimationTracks()) do
v:Stop(0)
end
end
end
welcomePlayerEvent.OnClientEvent:Connect(onWelcomePlayerFired)
I have both "push" and "push2" remote events in ReplicatedStorage.

2 comments
You should not use mouse.KeyDown as it is deprecated. Use UserInputService instead.
In the server script, why is the if condition in parenthesis? If you remove those, it may help, unless there is a reason for those parenthesis. Because of that, remote event 2 will not fire, meaning not much happens.