So let’s say we have a RemoteEvent in ReplicatedStorage called ‘DoUpdateStageValue’. (At least that’s what I think you’re trying to change.)
Remote:FireServer(...) is sent from the client. Think of it this way: It will tell the server, “Hey! I got a request for you. Please do something with the arguments I provided.”
Remote.OnServerEvent is an event that can be connected to. This will receive the Player and the arguments the Player sent.
We can put together something like this to change the value:
Server:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UpdateStageRemote = ReplicatedStorage.DoUpdateStageValue
UpdateStageRemote.OnServerEvent:Connect(function(Player, ToChange) -- Player is the player instance.
Player.Stage.Value = ToChange -- Make sure to do integrity checks. It's important! This is just a demonstration so it's not needed.
end)
Client:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UpdateStageRemote = ReplicatedStorage.DoUpdateStageValue
UpdateStageRemote:FireServer(1) -- where 1 is the value to set the stat to
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("remoteEvent")
remoteEvent.OnServerEvent:Connect(function(plr, job, msg)
if job == "updateStage" then
plr.Current.Value = msg
elseif job == "updateSpawn" then
plr.SpawnPoint.Value = msg
end
end)
Is this correct? Now I have to put the FireServer() in the MouseButton1Click events correct?
When you FireServer you pass to arguments (this is not a rule, this is literally what you done up there), “updateStage” and 3.
On the OnServerEvent you receive 3 arguments, plr, job, msg. Plr is the argument roblox adds, which is the player who fired it. The other two are the arguments you name, the arguments you send on the FireServer. So if you sent “updateStage” and 3, job and msg will be “updateStage” and 3 correspondingly
remoteEvent.OnServerEvent:Connect(function(plr, job, msg)
if job == "updateStage" then
plr.Current.Value = msg
elseif job == "updateSpawn" then
plr.SpawnPoint.Value = msg
end
end)
plr - the player
job - what you are wanting to update
msg - the new value
msg can be changed to anything like number, stagevalue, etc.
it’s essentially what is being said earlier. Remember, you can’t change values in a local script because the server can’t see it, only the client. That’s why you need this remote event.