Why won't the filtering work and why won't the text color change? Please help?
local RepStorage = game:GetService("ReplicatedStorage") local Remote = RepStorage:WaitForChild("BasicNametagRemote") local TextService = game:GetService("TextService") Remote.OnServerEvent:Connect(function(player, NameChoice, ColorChoice) local NameFilteredChoice = TextService:FilterStringAsync(NameChoice, player.UserId) local PlayerName = player.name local Nametag = game.ReplicatedStorage.CloneableObjects.Nametag:Clone() Nametag.Parent = game.Workspace[PlayerName].Head Nametag.NameLabel.Text = NameChoice Nametag.NameLabel.TextColor3 = BrickColor.new(NameFilteredChoice) end)
Error: ServerScriptService.BasicNametagCreator:11: bad argument #1 to 'new' (Color3 expected, got Object)
Your using BrickColor.new
, so it will error since your accessing the Color3 value of the part. Just use Color3.new
instead. Its also suggested to use Color3.fromRGB
since it uses Red, Green and Blue unlike Color3.new
which you need to divide by 255.
local RepStorage = game:GetService("ReplicatedStorage") local Remote = RepStorage:WaitForChild("BasicNametagRemote") local TextService = game:GetService("TextService") Remote.OnServerEvent:Connect(function(player, NameChoice, ColorChoice) local NameFilteredChoice = TextService:FilterStringAsync(NameChoice, player.UserId) local PlayerName = player.name local Nametag = game.ReplicatedStorage.CloneableObjects.Nametag:Clone() Nametag.Parent = game.Workspace[PlayerName].Head Nametag.NameLabel.Text = NameChoice Nametag.NameLabel.TextColor3 = Color3.fromRGB( a Color3 value) end)
though if your NameFilteredChoice parameter is a BrickColor
then you need to switch it to a Color3
value.