So I have recently been looking at tutorials on making chat GUIs on the roblox wiki pages. All of the tutorials I found were for "player.Chatted" which is not what I want. I decided to use some of the scripts in the tutorial and see if I could do something else for what I am trying to do. What I am trying to do is basically try to make a "texting" app of some sort, like you see on the chatting radios in some games, except players chat to make a message appear on the interface. I am trying to make it to where you type in a box, click "send" and it appears on a radio or a frame. The only error I am getting is on line 9 under "newchatline"(W003: Global 'newchatline' is only used in the enclosing function; consider changing it to local). I've inserted this local script into the text button named "Send":
wait(1)
game:GetService("Players").PlayerAdded:connect(function(player)
script.Parent.MouseButton1Click:connect(function(msg)
if script.Parent.Visible == true then
for _,v in ipairs(game:GetService("Players"):GetChildren()) do
for i,oldmsg in ipairs(v:WaitForChild("PlayerGui").ChatFrame.ChatBox:GetChildren()) do
end
newchatline = Instance.new("TextLabel",v:WaitForChild("PlayerGui").ChatFrame.ChatBox)
newchatline.Text = player.Name.. ": " ..msg
newchatline.Size = UDim2.new(1,0,0,15)
newchatline.Position = UDim2.new(0,0,1,-15)
newchatline.Font = "SourceSansBold"
newchatline.TextColor3 = Color3.new(1,1,1)
newchatline.TextStrokeTransparency = 0
newchatline.BackgroundTransparency = 1
newchatline.BorderSizePixel = 0
newchatline.FontSize = "Size14"
newchatline.TextXAlignment = "Left"
newchatline.TextYAlignment = "Top"
newchatline.ClipsDescendants = true
newchatline.Name = "line1"
end
end
end)
end)

1 comment
(W003: Global 'newchatline' is only used in the enclosing function; consider changing it to local) that is not an error it's roblox tells you that it should be local because it's only used as it says in enclosing function!