-
What do you want to achieve?
I have a billboard GUI with a textlabel named “PlayerName” using PlayerAdded, and CharacterAdded events a function clones this GUI from replicated storage parents it to the players head, and then fills the “.Text” with the player’s name. In a seperate script I have a function that fires a remote call to change the “.Text” field with user-inputted text from a TextBox in a menu GUI. I want the behaviour to be that the initial player name that is placed into “.Text” is replaced with the user-inputted text from the TextBox in the GUI. -
What is the issue?
Right now the TextLabel is retaining the initial player name overlaying the user inputted text. Upon changing the user inputted text it properly updates, YET retains the overlaying player name text which is not proper behavior! In a sense it’s “doubled” the text label. -
What solutions have you tried so far?
Cloning a bilboard gui from a freemodel script that was working properly (incase there were weird settings I had selected inside of my billboard gui)
Disabling Scripts and Screen Gui
Commenting out line 15 on the “BillboardGuiName” Server Script.
(This gives me the behavior I want with the TextBox, but does not start the player off with their username, which is something I want)
Below is BillboardGuiName Script
--##Services##
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--local chatService = game:GetService("Chat")
--##Variables##
local NameChangeEvent = game.ReplicatedStorage.NameChange
--##Functions##
--Below needs to be rewritten to work with NameChangeEvent connect
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local clonedobject = ReplicatedStorage.BillboardGui:Clone()
clonedobject.Parent = workspace:WaitForChild(player.Name).Head
workspace:FindFirstChild(player.Name).Head:WaitForChild("BillboardGui").PlayerName.Text = player.Name
end)
end)
function NameChange(player, text)
local name
local suc,err = pcall(function ()
local filtered = game:GetService("Chat"):FilterStringForBroadcast(text, player)
print (filtered)
workspace:FindFirstChild(player.Name).Head:WaitForChild("BillboardGui").PlayerName.Text = filtered
end)
if not suc then
name = "Filtering error: "..err..", please try again."
end
end
NameChangeEvent.OnServerEvent:Connect(NameChange)
--TODO Max character limit that makes sense with bilboard gui/ text input size.
Below is local script that goes into GUI
--##SERVICES##
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--##VARIABLES##
local acceptUserInput = true;
local player = game.Players.LocalPlayer
local gui = player.PlayerGui.ScreenGui.ClassMenuFrame
local roleplaybox = gui.RolePlayBox
local NameChangeEvent = game.ReplicatedStorage.NameChange
local mouse = player:GetMouse()
--local name
--##FUNCTIONS##
UserInputService.TextBoxFocused:connect(
function()
acceptUserInput = false;
end
)
UserInputService.TextBoxFocusReleased:connect(
function()
acceptUserInput = true;
end
)
UserInputService.InputEnded:connect(function( inputObject, gameProcessedEvent )
if (gameProcessedEvent) then
return
end
if (acceptUserInput) and (inputObject.UserInputType == Enum.UserInputType.Keyboard and inputObject.KeyCode == Enum.KeyCode.T) then
-- open/close GUI
gui.Visible = not gui.Visible
end
end)
roleplaybox.FocusLost:Connect(function(enterPressed)
if enterPressed then
print("Focus was lost because enter was pressed!")
local name = roleplaybox.Text
NameChangeEvent:FireServer(name)
end
end)
Billboard gui is located in ReplicatedStorage
and Remote Events are located in ReplicatedStorage