Server Script is not reading Value

Hello Developers,
Im currently making a Race ( a button appears for each client every 5 minutes, it is a script inside workspace ). When you accept the Invite a Value in the Workspace script (IntValue, called Competitors) gets the value +1. So if 6 players take part the value is = 6. The Value also resets to 0 when the race finished. I made this function because i want a player limit, so only if 2 competitors or more take part, the race starts, else it just breaks up and the Invite message appears again after 5 minutes. Im using a while true do loop in the script and a FireAllClients function to make the Guis visible for everyone and so on…
I tried adding this function inside of the loop
´´´if script.Competitors.Value > 1 then
(Race goes on Stuff)
else
(Race breaks up stuff)´´´
The Error here is that it just doesnt works… Even if the Value is over 2 it still breaks up. Also no errors are shown in output. Any help would be appreciated! :smile:

2 Likes

So I assume you’re trying to make an invite to race each five minutes and make it show how many players are in this race, is that correct?

1 Like

I already made the whole system, i just want that the race only works if there are two or more competitors in the race. For this i made the competitor Value (everything else works, i dont know why the function as given above doesnt works in the server script)
Heres the game link:
https://www.roblox.com/games/9466579355/Race-System

1 Like

Can you show us your script please?

4 Likes

It is just a game loop which fires multiple remote events, Ihave like 10 scripts handling the local gui if the player accepted the race. You can try out the linked game. When you accept the race you get teleported to the race start. The function that happens after should not work because you are only 1 person who participated.

1 Like

Show us the script to understand what’s going on and what’s the error just send it

1 Like

Deleted Post from 0xzMq - Script got fixed

1 Like

This script is very messy, things that should be indented aren’t. I recommend formatting it. In the second to last line you used ‘game.Players.LocalPlayer’ which cannot be used server side, and therefore, is most likely the problem here. Also sorry I edited this like 5 times I kept on noticing mistakes lol.

Oh sorry that script is for a button in starter gui.

In the description you said it was in the workspace?

I mean this function. The rest is in the serverscript in workspace

Ok, then the issue is changing the value client-side. If you change a value client-side it stays client-side. In other words, it will remain the same for the server.

2 Likes

Is there a solution how to fix this?

Change the value server side. You could use a remote event to achieve this.

Oh so i have to fire the server if the button is clicked. Amd in the server script i have to add the value. Would this work?

? This is the script im already using in Starter Gui. Also i think you accidently duplicated your message.

I think If you change value in Client, It will be changed only in client.
So you have to use RemoteEvent and change value in ServerScript.

Yes, as long as the value is changed by the server.

Can you show us what the repstorage.racevents.racestarts looks like you may have an event that fires when the race ends and that could cause the problem send a sceenshot of it

This event is just that the Race Invite Gui pops up for every player. If they click no it just disappears and when they click yes they get teleported to the race. There are no errors with or without the function :slight_smile:

1 Like