Is there a way to pass from client to client?

So I’m making a time trial and I have a local script in a part and one in a gui. When the player touches the part, it will start a script to make a timer in the gui.

However, they’re both client sided and I’ve actually only ever passed from the client to the server since I mainly just experiment. Is there any efficient way to do this?

(Edit: I might’ve misunderstood the question, this response only applies if you’re looking to pass data from 1 client to another client)

Well it depends, if you want reliability you need to do client → server → client. If you aren’t concerned for reliability then you could probably listen to part.Touched on the client to listen for other players as it does fire for other players. But again it isn’t the most reliable solution

BindableEvents ModuleScripts _G can be used to send Data from Script to Script

_G is a Global Variable you can use to send Data between Scripts

_G.Data = "string"
print(_G.Data) -- "string"

Note that this Method can only be used within the Context Level of your Script. So if you have a Variable on the Client, that Said variable can only be used on the Client.

BindableEvents are basically Custom Events, unlike RemoteEvents they dont send Data between Context Levels, You would need to set up the Event and fire it manually:

Bindable.Event:Connect(function()
    -- code
end)
Bindable:Fire() -- Fires Bindable Event

ModuleScripts can be used for both Server and Client, you would use require() access the Module, Depending on where you require() it, that’s where it would run.

local module = {}
module.Number = 1
return module
local module = require(ModuleScript)

print(module.Number) -- "1"

If you intend to fire something to ALL clients (as in Players), use a RemoteEvent, set it up on the Client, and use the FireAllClients method to Fire to All Players. which would basically be what @7z99 said here:
Client Event -> Server ( Only Server can fire this Event) -> Firing To All Clients

Or, For a Server wide effect, You would Set it up on the Server, and Fire it on the Client (However for this case, you can just use the Server)


Links Provided if you would Like to know more:

ModuleScript
_G

BindableEvent
RemoteEvent


@tuxe_t
For your case of a Time Trial game, It would be best to Manage Times on the Server and Effects on the Client, this is so hackers cant just change the Time, or suddenly have a Absurd Score, It is best to Never trust the client with specific endeavors for this reason.

It is also best to consider Securing your RemoteEvents as they can be fired quite Easily.

5 Likes

Hey sorry for the late response but I’m confused about how I would manage times on the server. If I want a GUI to show the time, I want it just for that player, not the entire server to see someone else time so how would I manage time on the server?