im making a custom chat thinging and its erroring Chat is not a valid member of PlayerGui
script: ```
local Players = game:GetService(“Players”)
local LocalPlayer = Players.LocalPlayer
local function RemoveSpaces(String)
return String:gsub("%s+", “”) or String
end
local function FindPlayer(String)
String = RemoveSpaces(String)
for _, _Player in pairs(Players:GetPlayers()) do
if _Player.Name:lower():match(’^’… String:lower()) then
return _Player
end
end
return nil
end
Your script is so confusing, why are you getting LocalPlayer at the top of the script? You literally have a player argument at the PlayerAdded function so why do you then fire the FindPlayer function if you literally already have the player object? Are you sure FindPlayer is even returning something?
i fixed alot and now its not working and no errors
localscript local Players = game:GetService(“Players”)
local function RemoveSpaces(String)
return String:gsub("%s+", “”) or String
end
local function FindPlayer(String)
String = RemoveSpaces(String)
for _, _Player in pairs(Players:GetPlayers()) do
if _Player.Name:lower():match(’^’… String:lower()) then
return _Player
end
end
return nil
end
game.ReplicatedStorage.SendChat.OnClientEvent:Connect(function()
local playertochat = game.Players.LocalPlayer
playertochat:WaitForChild(“PlayerGui”,5):WaitForChild(“Chat”):WaitForChild(“Frame”).ChatBarParentFrame.Frame.BoxFrame.Frame.ChatBar:CaptureFocus()
playertochat:WaitForChild(“PlayerGui”,5):WaitForChild(“Chat”):WaitForChild(“Frame”).ChatBarParentFrame.Frame.BoxFrame.Frame.ChatBar.Text = “I Like Almonds”
playertochat:WaitForChild(“PlayerGui”,5):WaitForChild(“Chat”):WaitForChild(“Frame”).ChatBarParentFrame.Frame.BoxFrame.Frame.ChatBar:ReleaseFocus(true)
end)