Is there a better way to transmit info from client to server without using RemoteEvents?

Script:

player=game.Players.LocalPlayer
SpdMultiChanged=game.ReplicatedStorage.SpdMultiChanged
button=script.Parent
local moduleSc = require(game.ReplicatedStorage.Abbreviate)
SpdMulti=game.Players.LocalPlayer:WaitForChild("OV").SpdMulti
Insights=game.Players.LocalPlayer:WaitForChild("OV").Insights
Cost=game.Players.LocalPlayer:WaitForChild("OV"):WaitForChild("SpdMultiCost")
button.Text="(+) "..Cost.Value
button.Activated:Connect(function()
	if Insights.Value>=Cost.Value then
		Insights.Value-=Cost.Value
		Cost.Value*=1.5
		Cost.Value=math.round(Cost.Value*100,Cost.Value*100)/100
		SpdMulti.Value*=2
		button.Text="(+) "..moduleSc.abbreviate(Cost.Value)
	end
end)

local function CharacterAdded(char)
	--Character added code
	button.Text="(+) "..moduleSc.abbreviate(Cost.Value)
end

local function PlayerAdded(player)
	--Connect the event
	player.CharacterAdded:Connect(CharacterAdded)

	--Take care of when it already exists
	local char = player.Character
	if char then
		CharacterAdded(char)
	end
end
game.Players.PlayerAdded:Connect(PlayerAdded)

for i,v in pairs(game.Players:GetPlayers()) do
	PlayerAdded(v)
end
SpdMulti.Changed:Connect(function()
	SpdMultiChanged:FireServer(SpdMulti.Value)
end)

Insights.Changed:Connect(function()
	game.ReplicatedStorage.InsightChanged:FireServer(Insights.Value)
end)

Provide an overview of:

  • What does the code do and what are you not satisfied with?
    This code increases cost, decreases insights and Spd Multi(i have duplicates for others but with variables slightly changed(like SpdMulti->VitMulti)) and I am not satisfied with having to make a remote event for every variable value I want to save (I have 7 and will have to make 3 more to save the cost variables).
  • What potential improvements have you considered?
    I have considered using scripts instead of local script for the buttons (but that did not work)
  • How (specifically) do you want to improve the code?
    I want to improve my code to be more efficient at transmitting info to the server for saving. If there are any nitpicks you might have about this, please tell me :slight_smile:
1 Like

If you don’t want to use a remote for each variable, then you could use one remote and pass an additional parameter for the value you’re changing. For example, you could fire a remote event UpdateValue that takes parameters name and value, the name could be SpeedMultiplier and value could be 2.

1 Like

BRO. You might not believe this but I thought of your exact solution a couple minutes ago, implemented it and came to put it as a solution! I’ll put yours as a solution however, since yours was first! Thanks for the help!

1 Like