- What do you want to achieve?
I want to create a script that automatically filters a textbox instance when a player types in it.
- What is the issue?
I am getting a weird error that claims that my filteredresult is an instance, not a string, and I don’t understand why.
- What solutions have you tried so far?
I’ve changed the variables around, I’ve tried looking on the official developer page for a solution. Maybe I haven’t found the right thing?
There are two scripts, a local script which is shown below. It fires a remote event with a script attached to it when the text property is changed.
script.Parent.Changed:Connect(function(Text)
if Text == "Text" then
script.RemoteEvent:FireServer()
end
end)
This is the script that is causing problems…
script.Parent.OnServerEvent:Connect(function(Player)
local TextService = game:GetService("TextService")
local gamenamecomponent = script.Parent.Parent.Parent ----- this is the textbox
local textofilter = "" --- string
local filteredresult = TextService:FilterStringAsync(textofilter, Player.UserId)
gamenamecomponent.Text = filteredresult
end)
The script gets the textbox, it then creates a variable named textofilter. This variable is supposed to be the textbox text. The textservice is supposed to filter it and turn it into a string. But for some reason it ends up being an instance?
21:06:46.205 Unable to assign property Text. string expected, got Instance - Server - Script:9
21:06:46.206 Stack Begin - Studio
21:06:46.206 Script ‘Players.Sidglz.PlayerGui.MakeGame.UnityBackground.GameName.LocalScript.RemoteEvent.Script’, Line 9 - Studio - Script:9
21:06:46.206 Stack End - Studio
^^ Error report