Values not changing?

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