#Value change

1 messages · Page 1 of 1 (latest)

heavy vault
#

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?

bronze rapidsBOT
#

studio** You are now Level 5! **studio

gleaming island
#

However if the opposite would occur, that is the intvalue was updated through the server, then the int value would change locally

heavy vault
#

how can I then change it? I need to let the script know which button activated the remote

patent arch
#

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

heavy vault
#

1 sec. Imma send the other script

patent arch
#

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.

heavy vault
#

so I can just put tonumber(i) in the local script?

#

but how do I acces it in the other one?

patent arch
#

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)

heavy vault
#

so I just need to do sth like local PB = tonumber(i)?

#

and the 2nd script knows what tonumber(i) is?

patent arch
#

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

heavy vault
#

what you mean the same place?

patent arch
#

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.

bronze rapidsBOT
#

studio** You are now Level 1! **studio

patent arch
#

in your case it dosen't really matter since your only passing through 1

heavy vault
patent arch
#

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.

heavy vault
#

ight

#

ty

#

Imma try that rq and tell u if there are problems

patent arch
#

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.

heavy vault
#

I think... I have a problem

patent arch
#

uh oh

heavy vault
#

I tested it by printing the tonumber(i) but it doesn´t print the number. It prints my name...

#

oh

#

now it works

patent arch
#

thats weird

heavy vault
#

I changed the variables name. Maybe the name I gave it has a diff meaning

patent arch
#

could be

#

everything works now?

heavy vault
#

@patent arch u still there?

patent arch
#

yes

heavy vault
#

it just does nothing

#

no errors. If I click the button, it just does noting

patent arch
#

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

heavy vault
#

it does print no matter which button I click

#

all 4 buttons work

patent arch
#

ok good so at least its getting there

#

hmmm

heavy vault
#

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

patent arch
#

ah

bronze rapidsBOT
#

studio** You are now Level 2! **studio

heavy vault
#

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

patent arch
#

omg that completley flew over my head

#

yes i think you need to update it w/ plrgui

heavy vault
#

can I also tranfer the player when calling the remote in the local script?

patent arch
#

yeah thats the plr paremeter in the funciton

heavy vault
#

what if I out everything inside of the function?

patent arch
#

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

heavy vault
#

ahhhh I get what u mean

patent arch
#

i gtg now but just tag me if you have any questions

heavy vault
#

1 sec

#

can I get the updated text in a local script like this?

patent arch
#

hold on give me a few minutes

heavy vault
#

can I put local scripts in ServerScriptService?

patent arch
#

you can’t unfortunately

heavy vault
#

do I need a 2nd local script to update the text or can I just put it in the already existing one?

patent arch
#

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?

heavy vault
#

yes it does. I am trying to do that rn

#

erm

#

why does it do nothing?

#

do I need a 2nd remote?

patent arch
#

shouldent need one

#

Ummmm

#

is the print statement on the server still running

heavy vault
#

that is why I was wondering

patent arch
#

And you removed the 3 lines that changed the text on the server right

heavy vault
#

erm

#

this is what is left

patent arch
#

Woah woah where did the :fireallclients thing go

bronze rapidsBOT
#

studio** You are now Level 3! **studio

heavy vault
#

I added that back

bronze rapidsBOT
#

studio** You are now Level 6! **studio

patent arch
#

Does it do anything now

heavy vault
#

nope

#

I changed some stuff. Here are the new pics

#

I am using 2 remotes now

#

whops little typing mistake 🙂

patent arch
#

That’s ok see if those fix everything

heavy vault
#

I think Ik what is wrong

#

the client doesn´t get fired at all

#

it also doesn´t print

patent arch
#

Yeah this is really strange

heavy vault
#

but why doesn´t it fire?

patent arch
#

I have a lot of trouble visualizing these with these server-client communication stuff

#

I’ll look again

heavy vault
#

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

patent arch
#

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

heavy vault
#

@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

patent arch
#

That’s annoying

heavy vault
#

ye. Imagine looking at this for 5 hours already...

#

then yk how my day was

patent arch
#

It happens to the best of us 😔

#

Can you sent both of your scripts again

heavy vault
patent arch
#

try swapping around num and plr in your server function bc plr is always first

patent arch
#

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

gleaming island
gleaming island
#

trying changing _ into another vairable like Button or something

#

I see a red line there

heavy vault