How do i send an event from server to client properly?

I want to make a script that send an event to a specific client, the problem is that i don’t know how i should do that, my solution was send the client’s name in the event, but hackers can fire that event to other players when they want. There’s another solution? Thanks for reading.

When you call FireClient you pass in the player instance first then the other arguments. Since it’s being done from the server hackers can’t make it fire to other players.

You can use either InvokeClient or FireClient, if you don’t need the results from InvokeClient then you should use FireClient, as it doesn’t need to wait for a response.

Basically what @Blokav said though, if you’re concerned about security.

The first argument in FireClient() should be the player you want it to fire to.

Hello, so, you can use :FireClient and :FireAllClients()

So for example, let’s suppose, you have a text right?

game.ReplicatedStorage.Event.OnClientEvent:Connect(function(msg)
script.Parent.Text = msg
end)

-- and From serverside:

game.ReplicatedStorage.Event:FireClient(--[[InstancePlayer--]] game.Players.Conejin_Alt, "Message is this one!")

--Here you're firing the event, to ONE single player, so the text will change only for that certain player,
If you make this:
game.ReplicatedStorage.Event:FireAllClients("Message is this one!")-- This fires for ALL players, this means, every player on the game will get the message.

2 Likes