Help with firing a remote event Client -> Server

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear! I want to fire a remote event to show the messages defined in the script for everyone that is the rank moderator

  2. What is the issue? I’m unsure how to use a remote event

  3. What solutions have you tried so far? I tried to fire the server and do the on server event but no luck

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Client

local Remote_Event = game.ReplicatedStorage.RemoteEvent
local Called = false
local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local Player = game.Players.LocalPlayer
local Frame = game.Players.LocalPlayer.PlayerGui.ScreenGui.Report_Menu
local Button = script.Parent
local Ranks = {Player:GetRankInGroup(10886396), -- was 1
	Player:GetRankInGroup(10886396,255)
}

local Messages = {game.Players.LocalPlayer.PlayerGui.ScreenGui.Sucess,
	game.Players.LocalPlayer.PlayerGui.ScreenGui.Submit.Error
}

Button.MouseButton1Click:Connect(function()
	Remote_Event:FireServer()
	wait(1)
	print("Thanks for submitting")
	wait(1)
	Frame.Visible = false
	Called = true
	if Called == true and game.Players.LocalPlayer:GetRankInGroup(10886396) < 255 then -- specified for players less then moderator rank
		print("Sucessfully submited the Report")
		Messages[1].Visible = false
		Messages[1].Visible = true
		wait(30)
		Messages[1].Visible = false
		
	else 
		Called = true and game.Players.LocalPlayer:GetRankInGroup(10886396,255) -- the group rank for your admins
			print("The Player Rank is Moderator")
			wait(1)
			print(Player.Name .. "A new report has been recieved")
			Messages[2].Visible = true
			wait(30)
			Messages[2].Visible = false
		end
end)
local Remote_Event = game.ReplicatedStorage.RemoteEvent

Remote_Event.OnServerEvent:Connect(function()
	-- how do i even show a UI for all player's?
-- Code
end)

Server

Hello I’m trying to fire a remote event to get my GUI to show for everyone who is the rank Moderator, but the problem is I’m not sure how to can someone please explain how to do this because it’s confusing. Thanks for your help.

1 Like

Something like this should be on the server script. However I did not test the code whatsoever.

local Players = game:GetService("Players")

local remoteEvent = game.ReplicatedStorage.RemoteEvent
local groupsToCheck = {10886396, 10886396}

local modId = 255 -- replace to the mod's role id
local playerRanks = {
	["james_m98"] = { -- example
		135,
		255,
	}
}

remoteEvent.OnServerEvent:Connect(function(player)
	for playerName, rankIds in pairs(playerRanks) do
		for _, id in ipairs(rankIds) do
			if id >= modId then
				if playerName ~= player.Name then -- make sure we wont send the message to ourselfes
					remoteEvent:FireClient(Players[playerName], "My message!")
				end
			end
		end
	end
end)

Players.PlayerAdded:Connect(function(player)
	local rankIds = {}
	for _, id in ipairs(groupsToCheck) do
		local result = player:GetRankInGroup(id)
		rankIds[#rankIds + 1] = result
	end
	
	playerRanks[player.Name] = rankIds
end)

-- garbage collection, to prevent memory leak :)
Players.PlayerRemoving:Connect(function(player)
	if playerRanks[player.Name] then
		playerRanks[player.Name] = nil		
	end
end)

Hope this helped!