I want to change a value of int value ++

  1. What do you want to achieve? Keep it simple and clear! I want to make a textbutton to change a value of “IntValue” . the value comes from the textbox when I trigger the textbutton it will change the value of the intvalue t o the textbox value then the the surfacegui textlabel will change into the value of the int value.

  2. What is the issue? Include screenshots / videos if possible! The issue is I can’t find anything helpful to my proble,

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub? Yes, but nothing is helpful. I’m just a beginner.

I tried to make a script but it doesnt work.

I tried using remote events from client to server since i want to change the value from server

also it took me hours finding similar topics to mine but I can’t so I decided to ask the dev forum about this.

Is it right if I use an IntValue for a word with numbers?

No it’s not. int means integer, so it can only store numbers without a fractional part. Use a StringValue. If it is completely made out of numbers then it’s OK, but you’ll need to use tonumber.

I will show you my script:

Client:

local flightnumvalue = script.Parent.Parent.states.flightnum
local statesfolder = game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui').states
local texts = script.Parent.TextBox





for i,v in pairs(statesfolder:GetDescendants()) do
	print(v.Name)
	if v:IsA("TextLabel") then
		script.Parent.TextButton.MouseButton1Click:Connect(function()
			script.Parent.RemoteEvent:FireServer(v)		
		end)
	end
end

Server:

local texts = script.Parent.TextBox


script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr, v)
	local texts = plr.PlayerGui.a.TextBox
	local flightnumvalue = plr.PlayerGui.states.flightnum
	flightnumvalue.Value = texts.Text
	wait(1)
	v.Text = tostring(flightnumvalue.Value)
end)

@cnr123451 What do you think about my script is it right or not? Sorry I don’t know much about scripting.

Why did you use a RemoteEvent? You only modify the client’s GUI as far as I can see.

1 Like

I want it to show on every player in the game.

But you are modifying the players GUI, plr.PlayerGui. You aren’t modifying all players’ GUIs. You should add another RemoteEvent for that, and use FireAllClients.

Oh… , Do I fire the server script from local script?

Try editing your server script to this:

local texts = script.Parent.TextBox

script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr, v)
	local texts = plr.PlayerGui.a.TextBox
	local flightnumvalue = plr.PlayerGui.states.flightnum
	flightnumvalue.Value = tonumber(texts.Text)
	wait(1)
	v.Text = tostring(flightnumvalue.Value)
end)

Hope that helps!

1 Like

Thank you but it still doesn’t work.

The issue is, you’re trying to detect a player’s GUI from the server. These sorts of things don’t change on the server side, only the client. Consider instead getting the value of the box on the client side, then passing that value through the RemoteEvent for the server to use.

1 Like

Intvalue = number here
Just make sure the number is not over 9.223e18 because that is the maximum and will cause errors

1 Like