I have made a custom chat following a tutorial, and for some reason it is not working. I do not know if this is supposed to be in art support or if this belongs in scripting. I think it belongs in scripting because the messages are not showing up. Can you help me find out what is wrong?
Thing.rbxl (35.0 KB)
Corrected code:
local textbox = script.Parent.Chat.Send.TextBox
local holder = script.Parent.Chat.Holder
local event = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
local template = game:GetService("ReplicatedStorage"):WaitForChild("template")
textbox.FocusLost:Connect(function(enter)
if (enter) and textbox.Text ~= "" then
event:FireServer((textbox.Text))
else
warn("Enter Some Text")
end
end)
event.OnClientEvent:Connect(function(message, sendingPlayer)
local clone = template:Clone()
clone.PlayerName.Text = "[" .. sendingPlayer.Name .. "]:"
clone.Message.Text = message
clone.Parent = script.Parent.Chat.Holder
end)
Old Code:
local textbox = script.Parent.Chat.Send.TextBox
local holder = script.Parent.Chat.Send.Holder
local event = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
local template = game:GetService("ReplicatedStorage"):WaitForChild("template")
textbox.FocusLost:Connect(function(enter)
if (enter) and textbox.Text ~= "" then
event:FireServer((textbox.Text))
else
warn("Enter Some Text")
end
end)
event.OnClientEvent:Connect(function(message, sendingPlayer)
local clone = template:Clone()
clone.playerName.Text = "[" .. sendingPlayer .. "]:"
clone.message.Text = message
clone.Parent = script.Parent.Chat.Holder
end)
Most of your errors are capitalization and incorrect instance locations. Also, when receiving the sendingPlayer value you have to get the name as sendingPlayer will be sent as an instance instead of a string.
Be sure to add a UIListLayout to the Holder frame so your messages aren’t stacked on top of one another.
Also, may I ask where you got the tutorial for this from?
1 Like
I think I already did that, didn’t I? Where would I keep it in the holder frame?
just placed inside the holder frame
1 Like
So just inside? It will not have any children? It is by itself, right?
Yes.
Okay, thank you. Sorry for the stupid question, I am on a chromebook right now and I forgot that Holder has nothing in it.