Attempt to perform arithmetic (sub) on string and number

I’m trying to make a set seats function live for all players without them having to re-open the gui.

I stated the issue in the title.

I looked on the devforum and I found nothing with (sub)

Client Script: The important part is the :InvokeServer(“ecset”)

AdminFrame.SciGeneral.Submit.MouseButton1Click:Connect(function()
	ReplicatedStorage:WaitForChild("Main2"):InvokeServer("ecset")
end)

ServerScript: Again the important part is the “ecset”

local Main2 = game:GetService("ReplicatedStorage"):WaitForChild("Main2")

Main2.OnServerInvoke = function(plr, command)
	if command == "ecset" then
		for i,v in pairs(game.Players:GetPlayers()) do
			v.PlayerGui.SCIGui.Main.CheckInFrame.EcoFrame.SeatsLeftFrame.SeatNumber.Text = plr.PlayerGui.SCIGui.Main.AdminFrame.SciGeneral.EcoSeats.Text
		end
	end
end

Might be an obvious solution, but I’ve never had the error before.

what was the line that prints out the error?

nevermind

do this

tonumber(v.PlayerGui.SCIGui.Main.CheckInFrame.PeFrame.SeatsLeftFrame.SeatNumber.Text)

-- converts the Text (string) to a number
1 Like

Where would I put the text? Like how would I add the other part.

like this:

	if command == "ec" then
		for i,v in pairs(game.Players:GetPlayers()) do
			v.PlayerGui.SCIGui.Main.CheckInFrame.EcoFrame.SeatsLeftFrame.SeatNumber.Text = tonumber(v.PlayerGui.SCIGui.Main.CheckInFrame.PeFrame.SeatsLeftFrame.SeatNumber.Text) -1
		end
	end

I mean the part im trying is if command == “ecset” then not the “ec”. The “ec” and all those work just fine.

I want to set the TextBox’s text that I input into the CheckInFrames SeatNumber to that value.

either way you can’t subtract a number to a string

Im just trying to look how I could do this,

I have another way of doing it but that requires everyone to close their ui and then open it again. Not live update.

what is the problem with ecset anyways?

also you should still make the top if statements use tonumber() like how @RocketB0ii said

What would help with doing it “tonumber()”?

I already said it as a note

it converts a string to a number

if you looked at @RocketB0ii’s example you would know why

I did what @RocketB0ii said and it works but that’s not the thing I have an error with. Check the updated script I made.

Imagine your value is a string like this "555"

If you want to change it to a number simply just do this tonumber("555") – Turns into a number value

Okay thanks, but how would I solve my real issue?

does it still prints any errors? (30)

I’m sorry but ecset doesn’t even subtract anything, ik that error isn’t coming from there

Okay, I’m a little confused but where’s the error at, or at which line?