Let's say I want the server to show a GUI for all players, I could use a remote event with .OnClientEvent:Connect(function()) to make a GUI visible for all players. But what if, I want to make so the GUI will be visible for the player only if they meet a requirement (ex: having "a" in their name). How do I check each player's name inside the .OnClientEvent function?
#Question about Remote Events
38 messages · Page 1 of 1 (latest)
One message removed from a suspended account.
understand something
localscripts run on a player's computer
so each player has their own localscripts
if the code is inside a local script you can use Players.LocalPlayer to get the player that is running the script
Yes, but how do I know what player it is "looping" through?
Yes I know that
do you want to do the validation on the server or the client
client
it might be vulnerable to exploiters if you do it on the client
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Using :FireAllClients
:FireAllClients() sends a remote for all players right?
One message removed from a suspended account.
How do I make so I know which player it is currently itering
One message removed from a suspended account.
Like
print(player.Name)```
One message removed from a suspended account.
One message removed from a suspended account.
Can I use .LocalPlayer
One message removed from a suspended account.
One message removed from a suspended account.
Ok gimme a sec
you could just do
for player in Players:GetPlayers() do
remote:FireClient(player)
end
and do the validation in the loop
Exemple:
There is a :FireAllClients() that sends a remote to all players (let's say se have "Player1", "Player2" and "Player3"). When I handle that remote, so using .OnClientEvent, I would like to check if the player has "3" in their name, if so, then do something (a function) else do nothing
oh yeah
forgot about that 😅
thx!
they exploit using client-side scripts?
if you wanna do it with guis
id reccomend
-- (serversided)
local players = game.Players
local function displayUI(letter)
for i, player in pairs(players:GetChildren()) do
--loop thru name
local playerString = player.Name:split("") --
for i, v in pairs(playerString) do
if v == letter then
local UI = player.PlayerGUI.ScreenGUI.Frame.Visible = true -- (example)
print("player : " .. player.Name .. " had their UI turned on")
end
end
end
end
local remote = ...
local letter = "a"
remote.OnServerEvent:Connect(function()
displayUI(letter)
end
i dont really remember how :split works
string.split
youll have to look that up but this should be the basic premise of it