Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to change String Value?

So I have a text box and you can type in a city and it changes the string values value to the city you typed in. It works when I solo test it but when I test it on Roblox it doesn't work. What kind of remote event or function do I need?

local gui = script.Parent.Parent

local TinCity = script.Parent.City

local player = game:GetService('Players').LocalPlayer

local play2 = game.Workspace:FindFirstChild(player.Name)
print(play2)

TinCity.InputChanged:Connect(function()
	local CityV = play2.PlayersDetails.City
	CityV.Value = TinCity.Text
	if CityV.Value == TinCity.Text and CityV.Value ~= "" and CityV ~= "N/A" then
		gui.Enabled = false
	end
end)

2 comments

0

You need to use a remote event to set the text on the server side to display to all player. You also need to filter this text as it may contain profanity.

0

What would the remote event look like? I have tried it and I can't get it to work.

1 answer

Alright, here's what you have to do.

FIrst, create a script in ServerScriptService containing the following.

local RemoteEvent = Instance.new("RemoteEvent",game:GetService("ReplicatedStorage"))
RemoteEvent.Name = ("RemoteName");

RemoteEvent.OnServerEvent:Connect(function(ArgumentOne)
	if ArgumentOne then
		return(function()
			-- argumentone is the stringvalue's value in this case.
		end)
	else
		return error("Argument one missing or nil.")
	end
end)

Secondly, in your localscript you would fire the remote with the stringvalue's value.

game:GetService("ReplicatedStorage").RemoteName:FireServer(StringValue.Value)

That's how you pass information from the client to the server.

12 comments

0

The string value changes it won't go through to the server tho I need a remote event to change it cause it only changes for the client I just can't find how to set up the remote event.

0

alright, so pass the value to the server with a remote

0

The text has an input you type a City name and It changes the Strings Value to a city. That is fine. I don't want a new instance I want a way to send that data to the server from the client.

0

Again, use a RemoteEvent.

0

Yeah I know did you read my post? "What kind of remote event or function do I need?"

0

You need a RemoteEvent instance.

0

Alright, I redid my comment, that explains your issue.

0

Do whatever you want in the server script's returned function.

0

Okay let me test it out. If it works I will accept your answer. :)

0

When I try to get the ArgumentOne it is the players name not the Strings Value. How would I fix that?

0

I'm pretty sure that's buildtin to roblox, add a second argument, (ArgumentOne,ArgumentTwo) and set argument two like FireServer("put something random here","what you want to do here")

0

Yeah that's what I thought to cause the player is always passed through. Okay, that worked. I just had to change some stuff around and negated the returns your had.

This discussion is preserved as it was. New answers, comments, and votes are closed.