I am trying to make a roleplay First/Last name system with 2 Overhead GUIs with the following script, yes there is a client script firing the event but this script doesn’t work and it changes the Overhead GUI’s text to “Instance”.
I’m quite new to GUI scripting and such, so please understand.
local DataTable = {
["Roleplay Name"] =
{
["First Name"] = "",
["Last Name"] = "",
},
}
local billboardgui = game:GetService("ServerStorage"):WaitForChild("OverheadGui")
local textServ = game:GetService("TextService")
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(character)
local clonedgui = billboardgui:Clone()
local PlayerName = DataTable["Roleplay Name"]["First Name"].." "..DataTable["Roleplay Name"]["Last Name"]
clonedgui.Frame.TextLabel.Text = PlayerName
clonedgui.Frame.TextLabel.TextColor3 = Color3.fromRGB(13, 105, 172)
clonedgui.Parent = game.Workspace:WaitForChild(Player.Name).Head
end)
end)
game.ReplicatedStorage.ChangeRPName.OnServerEvent:Connect(function(plr, name)
local filteredObject
local filteredText
local success, err = pcall(function()
filteredObject = textServ:FilterStringAsync(name, plr.UserId)
end)
if(success) then
local complete, failed = pcall(function()
filteredText = filteredObject:GetNonChatStringForBroadcastAsync()
end)
if(complete) then
DataTable["Roleplay Name"]["First Name"] = filteredText
end
end
local gui = game.Workspace:WaitForChild(plr.Name).Head.OverheadGui
local PlayerName = DataTable["Roleplay Name"]["First Name"].." "..DataTable["Roleplay Name"]["Last Name"]
gui.Frame.TextLabel.Text = PlayerName
end)
game.ReplicatedStorage.ChangeRPName2.OnServerEvent:Connect(function(plr, name)
local filteredObject
local filteredText
local success, err = pcall(function()
filteredObject = textServ:FilterStringAsync(name, plr.UserId)
end)
if(success) then
local complete, failed = pcall(function()
filteredText = filteredObject:GetNonChatStringForBroadcastAsync()
end)
if(complete) then
DataTable["Roleplay Name"]["Last Name"] = filteredText
end
end
local gui = game.Workspace:WaitForChild(plr.Name).Head.OverheadGui
local PlayerName = DataTable["Roleplay Name"]["First Name"].." "..DataTable["Roleplay Name"]["Last Name"]
gui.Frame.TextLabel.Text = PlayerName
end)
Why is this happening and how can I fix it?