I cant seem to figure out why this Value wont update when its changed

game.ReplicatedStorage.Values.IsWorking:GetPropertyChangedSignal("Value"):Connect(function()
			print(game.ReplicatedStorage.Values.JobName.Value)
			while BaseStuff.IsWorking == true do
				local JobNameValue = game.ReplicatedStorage.Values.JobName.Value
				print("Work Check")
				print(JobNameValue, 'Name')
				local Job = JobData[JobNameValue]
				wait(Job.Tic)
				Simoleons.Value = Simoleons.Value + Job.CashPerTic
			end
		end)

When i change the JobName value to something else it does not change in the script. Any idea why? There are no errors and it works 90% except for this minor issue. This script is in serverscriptservice also.

Is the value being changed by a local script?

Yes its a button changing the value

Scripts can’t see LocalScript changes because they’re done on the client, you’ll need to change the Value on the server for example integrating a RemoteEvent to tell the server to change it.

1 Like

How would I go about doing that?

Simply, fire to the server when the button is clicked but remember the client then has full control over the Value.

eg. with a RemoteEvent named ChangeWorkingEvent inside ReplicatedStorage:

--// LocalScript, Button
local ReplicatedStorage = game:GetService("ReplicatedStorage");

local function Click()
    ReplicatedStorage.ChangeWorkingEvent:FireServer(true);
end

script.Parent.MouseButton1Click:Connect(Click);
--// Script, ServerScriptService
local ReplicatedStorage = game:GetService("ReplicatedStorage");

local function ChangeWorking(Boolean)
    ReplicatedStorage.Values.IsWorking.Value = Boolean;
end

ReplicatedStorage.ChangeWorkingEvent.OnServerEvent:Connect(ChangeWorking);

Multiple clients could mean this Value is changed by other clients, I suggest making one for each client.

1 Like

So its exploitable, how can i prevent them from manipulating the value?

You’re wanting it to be changed upon a click, there’s no way you could prevent them from clicking?

The value I want to change is JobNameValue, so i just do
Repstor.values.JobNameValue.Value = “Job”?
I suppose I could prevent them from randomly firing it

Yep and sanity checks can stop an exploiter from manipulating Remotes, let’s say for example you store a boolean on the server to reflect if it can be changed currently or not.

1 Like

Alright thanks man! Ill mess around with remote events

1 Like