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.
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.
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.
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.