Trying to :FireServer() Not working?

I’m trying to change a server value with a local script in a gui using :FireServer()
The problem that I’m having is the code runs without a problem without any errors but I see no results in the value changing.

Is there anything that I’m doing wrong or forgetting to do?

Thank’s in advance!


local TempTag = script.Parent.GenTag
local Generator = ""
			
for cycle, item in ipairs(workspace:GetDescendants()) do
		if item.Name == ("GenTag") and item.Value == (TempTag.Value) then -- official add progress	
		Generator = item.Parent.Parent					
		end
	end

UIS.InputBegan:Connect(function(inputObject) 
	if(inputObject.KeyCode==Enum.KeyCode.X)then
		HoldingKey = true
print("Xed")
		while HoldingKey do
			ReplicatedStorage.GeneratorEvent:FireServer(Generator.Stats.Progress.Value == Generator.Stats.Progress.Value +1)
			print("Fire")
			wait(0.2)
		end

	end
end)

``
1 Like

I alr saw the cod. You are sending a bool value? (true, false)

1 Like

You’re passing Generator.Stats.Progress.Value == Generator.Stats.Progress.Value +1 so it’s probably always sending false and not the value you want, maybe change the value before sending it

1 Like

Instead of this, do this:

Generator.Stats.Progress.Value += 1

It will give the result you want.

For example:

a.Value += 1

is the same as saying

a.Value = a.Value +1

Similar thing is when you subtract, -=
multiple *=

and so on

1 Like

Maybe he intended = and used ==
But if so, he would still need to pull that assignment operation outside the :Fireserver()

1 Like

what…

switch that to = or either just change it to Generator.Stats.Progress.Value + 1

1 Like

still if he changes it he will have to pull it outside the :Fireserver() or it will throw an error.

he needs this:

Generator.Stats.Progress.Value = Generator.Stats.Progress.Value +1
ReplicatedStorage.GeneratorEvent:FireServer(Generator.Stats.Progress.Value)

or += 1 like you say, but in two lines

1 Like

Hey, Thanks for your time but when I do it like that it’s just the red squiglly error line underneath.

the regular value+1 doesnt give the error line but it still doesnt change

Like this right?

ReplicatedStorage.GeneratorEvent:FireServer(Generator.Stats.Progress.Value +=1)
1 Like

Hey, Thanks for the reply. I tried to use this way but it still doesn’t change the value? Anything other ideas?

1 Like

I think we got it all wrong here. Instead of adding what change you want to make inside the parameter, I’d change it and add the value that you want to change (myValue.Value), and maybe as a second parameter add the amount, but the amount is best to be handled on the Server through the OnServerEvent function, protecting your value too by checking if it’s the correct one, so no exploiters could mess up with your values at any time.

Of course that wouldn’t fully protect your remote, just simply make your checks so you don’t get checked BOI have your remotes exploited by some kids.

If you need further help or some more explanation, you can ask.

I apologize if I’m wrong.

1 Like