Script doesnt register TextBox text

I have been trying to get text from a TextBox but it doesnt work for some reason.
This is a script.

if mode.Value == 5 then --Color
				local color = player.PlayerGui.LoadoutGui.Loadout.SpawnMenu.Loadout.RGB.Text
				if target.Locked == false then
					target.Color = Color3.fromRGB(color)
					print(color)
				end
			end
		end
2 Likes

Where is the script located and also did you define all the variables?

2 Likes

I suggest you add more checks to see if the code is really running example[should be used as an example]:

if mode.Value == 5 then --Color
                       print("The vaule is 5")
				local color = player.PlayerGui.LoadoutGui.Loadout.SpawnMenu.Loadout.RGB.Text
               print(color)
				if target.Locked == false then
           print("target is locked")
					target.Color = Color3.fromRGB(color)
					print(color)
				end
			end
		end
1 Like

I defined all of the variabled and the script is located in:
image

ToolServer script

1 Like

Did you get an error message? if not its probably because the mode.Value isnt 5

1 Like

Absolutely no errors.

Only " " gets printed (nothing).

Also the color of the part just turns to black no matter what RGB value you type in.

1 Like

Hm since you added a print(color) and it printed out nothing that would mean that there isnt text in the textbox, could you send a photo of the gui?

1 Like

Use a localscript. The server can’t get the text the player is typing.

1 Like

Use the checks suggested by @danielthedanman

1 Like

The 5 buttons on the top are modes.

The “0,255,0” on the bottom is what I typed into the TextBox

2 Likes

is the script a localscript? as said by @BilonGamer

2 Likes

As I stated in the description of the post, it is not.

2 Likes

Oh alright well in that case you have to use a localscript

3 Likes
I already tried and it had the same problem.

It literally just doesnt want to work.

local RGB = player.PlayerGui:WaitForChild("LoadoutGui")

local RGB1 = RGB.Loadout.SpawnMenu.Loadout.RGB.Text

task.spawn(function()
	while true do
		value.Value = RGB1
		print(value)
		wait(0.1)
	end
end)

Hold on just a minute

2 Likes

If you need the server to get the text, use a LocalScript, a Script and a RemoteEvent to send the text box’s text to the server.

2 Likes

Also, you can’t do Color3.fromRGB(text) as you cant use a string for a color. Separate the string using string.split(text, ",") and use these values instead.

2 Likes

I dont really understand RemoteEvents.

I looked at this and it didnt help at all: Remote Functions and Events

1 Like

Well, thats a thing to think about after I get through this TextBox heck.

(If it even registered it in the first place)

1 Like

I know kinda late but the only one that didnt work is print(color)

It printed nothing.

(I feel like this has already been established by now)

1 Like

Ok, so you have a RemoteEvent instance.
The client can do:

RemoteEvent:FireServer(data)

data being the thing the player sends

The server can do:

RemoteEvent.OnServerEvent(function(player, data)
    -- stuff here
end)

Connect an event that does stuff everytime the client does their thing, automatically receiving the Player instance of who did it and the data.

For your case you would check with the textbox’s event that lets you detect when the player inputs something in it and it would FireServer and the server can handle it.

2 Likes