Is it possible to convert data from a local script into a server script?

I’m new to scripting so I apologize in advance for any confusion or mistakes I make. So recently I scripted a code that is inside of a button, that upon clicked will start a countdown and after the countdown ends, a timer will start and after touching a part the timer will stop. I got that part working but the problem is that its all inside of one local script under the start button. I want to convert the data of the final time to the starting place of the game.

local finalTime = tonumber(startTimerLabel.Text)

above is the variable where I store my final time.
startTimerLabel is the textLabel where the timer is being updated and I have a code that freezes the timer when it touches a part.
I just want some general tips and pointers to avoid getting myself in a rabbit searching for a solution for hours

3 Likes

Yes, you can with RemoteEvents. RemoteEvent | Documentation - Roblox Creator Hub

2 Likes

sorry for the late reply but after some digging I think I would want a remote functions for two way communication between the server and client (client initiates the remote, server script does the countdown and timer logistics and sends back the data to the client) but i just read about Remote Events and Callbacks Documentation so sorry if this sounds stupid

2 Likes

So im unsure whether a Remote function or remote event would be better

2 Likes

If you need to transfer data from local to server or the opposite, use remote event, if for some reason you need a 2 way communication then use remote function

3 Likes

Use one or another to get the job done imo

3 Likes

Then as you said, RemoteFunctions would work well with that.

This is a good resource that teaches you how to use RemoteFunctions and RemoteEvents, have a look:

3 Likes

I wanted to have a 2 way connection because i watched a video about how cheaters can easily access the local side scripts, or something along the lines of that so im hesitant in programming the timer logistics in a local script. But again Im not 100% sure.

2 Likes

Cheaters could also send false data (using RemoteEvents and RemoteFunctions) to the server so I recommend having checks on the server if the data exists and is valid. Never trust the client with anything. Only trust the server.

4 Likes

you can use remote event while using the server to check if it the data exists like @lilmazen1234 said,
a remote can still be useful, but you always must have checks in the server script for security reasons

3 Likes

Okay thanks to both of you I’ll just do that for now.

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.