#Leaderstats ignoring subtraction of a value

23 messages · Page 1 of 1 (latest)

covert topaz
#

Ok does the script being a server script have any difference?

#

does it need to be local

fluid marsh
#

It can't be

covert topaz
#

cant be local or server?

fluid marsh
#

It can't be client-sided (local)

#

The changes you make to the player's leaderstats won't replicate

covert topaz
#

why is that? the collectable coins work just fine

fluid marsh
covert topaz
#

Ive read a portion of it and the interaction is a server to client interaction

fluid marsh
#

Your code does the following:

  1. Subtract cost from Player/leaderstats/Coins
  2. Load the previous recorded state of the player's coins
  3. Update the record to the new state of Players/leaderstats/Coins
  4. Overwrite the current state of Player/leaderstats/Coins to the previous state
#

The fourth operation is why you don't see the subtraction being made

#

You shouldn't be loading or saving the data in the first place

#

Not should the cost of something be defined in a ScreenGui

covert topaz
#

Replicated storage? thats where all of the other values i have stored are

neat stumpBOT
#

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

covert topaz
#

if this helps this is a part of the screen gui its what updates the cost

fluid marsh
#

Aye.

#

Throw that code away

#

You can't be doing any of this on the client

covert topaz
#

ok

#

I moved all both cost values to replicated storage and have them changed in another script which looks like this (this is a server script)

#

I also edited the og script and for some reason the cost2 value changes but when it is asked to print the coins it prints 3047 which was my coins before the subtraction