hello, I have 2 scripts which I want to make a vote system. One is the local script (the one you see) and the normal script isn´t shown. I have a textlable for each button in the table Buttons. To change the text of the correct lable, I need to know which button was activated which is why I have an IntValue which should save this value by using i (the key of the pressed button) and make it his value. Then in the other script I could just take the value, find the textlable with the correct key and change its text but the value of my IntValue doesn´t change when I click a button. Can someone tell me why?
#Value change
1 messages · Page 1 of 1 (latest)
** You are now Level 5! **
Changing an intvalue through a local script will not update it in the server
However if the opposite would occur, that is the intvalue was updated through the server, then the int value would change locally
how can I then change it? I need to let the script know which button activated the remote
why not pass that as an argument with the event you are firing on the next line
if your other script works the way i think it does then you should just be able to send that rather than using an intvalue
oh ok so yeah in the first script you should just be able to pass tonumber(i) with your remoteEvent, and then in the second script you add a parameter to that function you have, and then just sent that to the value of your variable.
so I can just put tonumber(i) in the local script?
but how do I acces it in the other one?
so in your local script, you put the tonumber(i) in the parentheses of the event. Like this:
PushServerEvent:FireServer(tonumber(i))
Then on the server, you can just put any variable name you want in the parameters of the function you have, and that will represent your tonumber(i)
so I just need to do sth like local PB = tonumber(i)?
and the 2nd script knows what tonumber(i) is?
you dont need too
you can just put any variable name inside of the parameters on your server script, they don't have to match up as long as they are in the same place
what you mean the same place?
like the same spot in the paremeters, heres what i mean:
FireServer(Value1, Value2, Value3)
OnServerEvent:Connect(function(firstvalue, secondvalue, thirdvalue)
They need to be in that specific order so the parameters get matched up with the right values.
** You are now Level 1! **
in your case it dosen't really matter since your only passing through 1
so I need to put the name of what I want to use from the local script in the parameters of the function?
you don't need to, because roblox dosen't care what the names of it are, they only care if they are in the right spot, and since you only have 1, you can pass through your tonumber(i) and in the server script, name it whatever you please.
no problem. One thing that i forgot to mention though is that you need to add a player paremeter in your server script function, because onserverevents automatically have a plr paremeter. So all you need to do is just add (plr, yourvariablename) in the parameters.
I think... I have a problem
uh oh
I tested it by printing the tonumber(i) but it doesn´t print the number. It prints my name...
oh
now it works
thats weird
I changed the variables name. Maybe the name I gave it has a diff meaning
I´ll finish the script and then tell u
@patent arch u still there?
yes
ok first i want to verify if the function is actually running so can you add a print statement inside of that function and click the button to verify its running
good news: I just let it print the texts of the buttons
they do update in my output but just not on screen
their text changes to 1,2,3 etc but not on screen
ah
** You are now Level 2! **
wait
no. I want it
I think Ik why
is it possible that I need to use playergui instead of startergui
only problem. There is no Player and with that no playergui in serverscripts :c
can I also tranfer the player when calling the remote in the local script?
yeah thats the plr paremeter in the funciton
what if I out everything inside of the function?
remove everything?
i think what you need to do now is save a vote counter on the server side and then sent a remoteevent back to the client that updates the votecounter for them
ahhhh I get what u mean
i gtg now but just tag me if you have any questions
hold on give me a few minutes
can I put local scripts in ServerScriptService?
you can’t unfortunately
do I need a 2nd local script to update the text or can I just put it in the already existing one?
nope the one you have is fine
So all you really have to do is reference the vote count text label just like you did in the server script and use a remote event to update it
So on the sever you will need variables to keep track of each of the options and their vote counts
Make sense?
yes it does. I am trying to do that rn
erm
why does it do nothing?
do I need a 2nd remote?
nope
that is why I was wondering
And you removed the 3 lines that changed the text on the server right
Woah woah where did the :fireallclients thing go
** You are now Level 3! **
I added that back
** You are now Level 6! **
Does it do anything now
nope
I changed some stuff. Here are the new pics
I am using 2 remotes now
whops little typing mistake 🙂
That’s ok see if those fix everything
I think Ik what is wrong
the client doesn´t get fired at all
it also doesn´t print
Yeah this is really strange
but why doesn´t it fire?
I have a lot of trouble visualizing these with these server-client communication stuff
I’ll look again
I´ll try find someone to also have a look at it
maybe someone with the scripter role... He is probably more experienced than we are
I think on the client you need to get the button from the buttons table
Bc I don’t think it’ll work that way because your passing through the text object and that might cause problems
@gleaming island U still there?
my whole studio is broke Ig
I changed most of the stuff back and it still doesn´t print anything when I use this
That’s annoying
try swapping around num and plr in your server function bc plr is always first
I already did that
sorry I have no idea what the issue is anymore
Id suggest making a devforum post
Or talking to someone more experienced if you can find one
show the function in which your are firing the remote event
do you get an error in your output?
trying changing _ into another vairable like Button or something
I see a red line there
no errors