I have a few textboxes for players to input information in, and I am trying the put the text inputted into some string values.
However, the the text in textbox only seems to change client side when a player inputs text…so it doesn’t grab the text the player inputted, and I have no idea how to get around this…
The script is shown below:
local CountryOwner = script.Parent.CountryInfo.CountryOwner.Value
local CountryCreation = game:GetService("Players")[CountryOwner].PlayerGui.CountrySetup.CountryCreation
CountryCreation.DoneButton.MouseButton1Click:Connect(function()
script.Parent.CountryInfo.FlagID.Value = CountryCreation.SetCountryFlag.TextBox.Text
script.Parent.CountryInfo.CountryCulture.Value = CountryCreation.SetCultureName.NonPlural.Text
end)
The Text property of a TextBox is not replicated to the server.Have the client fire a remote event whenever the DoneButton is clicked.
Edit: Here’s a fix:
-- server
local Replicatedstorage = game:GetService("ReplicatedStorage")
local CountryFlagEvent = Instance.new("RemoteEvent", ReplicatedStorage)
CountryFlagEvent.Name = "SetCountryFlag"
CountryFlagEvent.OnServerEvent:Connect(function(Player, FlagId, NonPluralText)
if Player == CountryOwner then
script.Parent.CountryInfo.FlagID.Value = FlagId
script.Parent.CountryInfo.CountryCulture.Value = NonPluralText
end
end)
-- client
local Players = game:GetService("Players")
loaal ReplicatedStorage = game:GetService("ReplicatedStorage")
local CountryFlagEvent = ReplicatedStorage:WaitForChild("SetCountryFlag")
local LocalPlayer = Players.LocalPlayer
local CountryCreation = PlayerGui.CountrySetup.CountryCreation
CountryCreation.MouseButton1Click:Connect(function()
CountryFlagEvent:FireServer(CountryCreation.SetCountryFlag.TextBox.Text, CountryCreation.SetCountryFlag.TextBox.Text)
end)
I am guessing the server code goes in a normal script and the client code goes in a local script…but where do I put them? Does the local script need to be in the player?