Taking code from a local script to a server side

You can write your topic however you want, but you need to answer these questions:
Hey, So I’ve been working on a project recently, I’ve come across an issue which I’ve tried, and still doesn’t work.

I am trying to get these lines below, from a local script into a script, and running it every .5 - 1.5 seconds.

tostring(math.floor(realSpeed+.5))
 and 
tostring(math.floor(RealHeading+0.5))

I have tried using a remote function but I did not get any results I wanted. These lines are used in the local script, I have also tried a remote event and still unsure on the way I could get these variables and place as a text in a text label.

Thanks.

What’s not working? Can you please be a little more descriptive? You’ve just given us 2 lines of code and asked to solve problems you haven’t even told us about.

I’m not sure if this is what you want, but you could just

TextLabel.Text = tostring(math.floor(realSpeed+.5))

So, I have a local script that is a gui that runs when a user is flying it, It has altitude, speed and heading as variables inside of the local script. this is the local script. I would like to try and get these two lines(posted above) from this local script to another gui.

I want to be able to have the values below filled as the ones in the local script. So the speed and heading is updated accordingly.

You can try making NumberValues in ReplicatedStorage, and set the value of those to the value of the variables in the updateGui script, and then use those values in the second script.

Basically,

  • Make 2 NumberValues in ReplicatedStorage
  • Name them RealSpeed and RealHeading
  • In the localscript with the updateGui function, at the end of the function set the value of them with something like
ReplicatedStorage.RealSpeed.Value = realSpeed
ReplicatedStorage.RealHeading.Value = RealHeading
  • Then, in the second localscript, at the top of the while loop, write
while true do
    wait(0.15)
    local realSpeed = ReplicatedStorage.RealSpeed.Value
    local RealHeading = ReplicatedStorage.RealHeading.Value
    <REST OF THE CODE HERE>
1 Like

I have just tested it, putting it into it’s code and It did not work. as you can see here, the values weren’t changing at all.

Are there any errors? I hope you’ve defined ReplicatedStorage.

It works now, thanks for the assistance! I had to remove a couple of lines above it.

You can use a modulescript 30charaaaac