Values not changing?

Are you values NumberValues? Make sure plr.Stats.Multiplier.Value is not 0. That’s the only reasons I can find. UwU

The IntValue is created on the server. (Heres a photo of the (glitch?) happening:

< That is with no changes yet.

They are IntValues, and the multiplier is 1. The values simply do not change.

Have you tried to declare

These as variables before changing the values?

local Stats = plr.Stats
local Coins = Stats.Coins.Value
local CurrentStorage = Stats.CurrentStorage.Value
local Multiplier = Stats.Multiplier.Value

Coins = Coins + CurrentStorage * Multiplier

CurrentStorage = 0
print(`done`)

My only guess now it could be your variables. One time I had an issue with a calculation not going through because I didn’t use variables.
Plus, use brackets to indicate what you’re actually multiplying?

I have not tried the following yet… But heres something very odd…

And no, the variables didn’t work either. What If I reference the values on the client side and told them to change on the server side of things?

Try to change the values on the server side

Nope… ;/ I’m so stumped, and this is a players data I’m risking… Oof

When and where do you change CurrentStorage?

For testing, I use a clickdetector to fire a remoteevent (the same one im using for this?) that fires the client and gives currentstorage value successfully.

But obviously I’ll change that when I’m further on into the games development.

Where do you change the variable? I believe you’re only changing the value locally because from the last screenshot you sent was your clients IntValue because of the blue highlight around your ROBLOX window. You need to be changing the values on the server.

Server script (In the clickdetector part)

 local function c(plr)

 game.ReplicatedStorage.GiveEvent:FireClient(plr)

 end

 script.Parent.ClickDetector.MouseClick:Connect(c)

And then my local script:
game.ReplicatedStorage.GiveEvent.OnClientEvent:Connect(function(plr)

 script.Parent.Parent.Stats.CurrentStorage.Value = 10

 end)

So basically, I should be using a bindable event instead of a RemoteEvent, correct?

Wait- How would I get the players name from a ClickDetector?..

Edit: Nvm

There’s no need to send an event to the client if you want to make changes on the server

You already collected the player obj through the parameters, just use that variable plr to change the values.

 local function c(plr)

plr.Stats.CurrentStorage.Value = 10

 end

 script.Parent.ClickDetector.MouseClick:Connect(c)

This way because its on a server script, you know that these changes can be seen on the server and not just the client.
Just remember, for the server to see changes, the server has to make those changes. The server has the authority over each players’ client.

I understand this isn’t a direct response to your question - I just want to point out the elephant in the room: with your current setup, exploiters can easily execute client-sided code to abuse the server. For example:

local event =  game.ReplicatedStorage.GiveEvent
for i = 1, 100000 do
	event:FireServer()
end

I would recommend adding in server-verification to minimise this abuse. For example, is the client sending more than one request a second? If so, block the request.

2 Likes

The selling now works… But now I can’t get the storage to 0…

Thanks! I’ll definitely be using something like this. :slight_smile:

Do the changes on the server, not the client. In your case it should be in an ordinary script not a localscript

Take this to Messages, I can sort out your issue there.

1 Like