So i was trying to make a custom chat, there are 2 scripts, the other in ServerScriptService is working alright, but the script inside the chat is not, its the script that shows the message.
SCRIPTS:
The Faulty Script:
local Player = game.Players.LocalPlayer
local OriginalText = "Click here or press '/' to send a message"
local Chat = script.Parent
local ChatFrame = script.Parent.MainCustomChatWindow
local ChatBar = script.Parent.MainCustomChatWindow.SendChatFrame.PlayerSendBox
local Frame = script.Parent.MainCustomChatWindow.PlayerTextBoxHolder
local UIS = game:GetService("UserInputService")
if UIS.TouchEnabled then
OriginalText = OriginalText
ChatBar.Text = OriginalText
end
UIS.InputBegan:Connect(function(Input, GameProcessed)
if GameProcessed then return end
if Input.KeyCode == Enum.KeyCode.Slash then
ChatBar:CaptureFocus()
end
end)
local function ChatFunction(Message)
game.ReplicatedStorage.Message:FireServer(Message)
end
ChatBar.FocusLost:Connect(function(EnterPressed)
if EnterPressed then
local Message = ChatBar.Text
if Message:len() > 0 then
ChatFunction(Message)
else
if Message:lower() == Message:upper() and Message ~= "" and Message ~= " " and Message ~= " " and Message ~= " " and Message ~= " " and Message ~= " " and Message ~= " " and Message ~= " " then
ChatFunction(Message)
end
end
end
ChatBar.Text = OriginalText
end)
ChatFrame.MouseEnter:Connect(function()
ChatBar.BackgroundTransparency = 0
Frame.BackgroundTransparency = 0
for i=1,5 do
ChatBar.BackgroundTransparency = ChatBar.BackgroundTransparency + 0.04
Frame.BackgroundTransparency = Frame.BackgroundTransparency + 0.04
wait()
end
ChatBar.BackgroundTransparency = 0.77
Frame.BackgroundTransparency = 0.77
end)
ChatFrame.MouseLeave:Connect(function()
ChatBar.BackgroundTransparency = 0.77
Frame.BackgroundTransparency = 0.77
for i=1,5 do
ChatBar.BackgroundTransparency = ChatBar.BackgroundTransparency - 0.04
Frame.BackgroundTransparency = Frame.BackgroundTransparency - 0.04
wait()
end
ChatBar.BackgroundTransparency = 0
Frame.BackgroundTransparency = 0
end)
game.ReplicatedStorage.Message.OnClientEvent:Connect(function(Message)
local i = Instance.new("TextLabel",Frame)
i.Size = UDim2.new(1,0,0.1,0)
i.TextScaled = false
i.BackgroundTransparency = 1
i.Font = Enum.Font.SciFi
i.TextStrokeTransparency = 0
i.TextColor3 = Color3.new(235,235,233)
i.Name = "Chat"
i.Text = Message
i.TextXAlignment = Enum.TextXAlignment.Left
i.TextYAlignment = Enum.TextYAlignment.Top
local t = Frame:GetChildren()
Frame:ClearAllChildren()
if #t > 10 then
table.remove(t,1)
end
for c,v in pairs(t) do
local l = v:Clone()
l.Position = UDim2.new(0,0, (c-1)*0.1,0)
l.Parent = Frame
end
end)
It is inside the ScreenGui of the Chat, not inside the ChatFrame so script.Parent = ScreenGui
It is probably cloning itself and trying to find Position on it, which does not exist but I don't know how to fix it or why it is happening
It is having errors at line 75: l.Position = UDim2.new(0,0, (c-1)*0.1,0)
This is a LocalScript
And the other script:
local ReplicatedStorage = game.ReplicatedStorage
local MessageEvent = ReplicatedStorage.Message
local APrefix = [[/]]
local Owners = {"166660143", "260932086"}
local Admins = {"166660143", "260932086", "1466856081", "310333010"}
local function IsOwner(p)
local n = p.UserId
for _,v in pairs(Owners) do
if v == n then
return true
end
end
return false
end
local function isAdmin(p)
local n = p.UserId
for _,v in pairs(Admins) do
if v == n then
return true
end
end
return false
end
local function Chat (p,m)
local Name = p.Name
local Message = game.Chat:FilterStringForBroadcast(m,p)
local Nick = p:FindFirstChild("Nickname") if Nick then Name = p.Nickname.Value end
local Prefix = p:FindFirstChild("Prefix") if Prefix then Name = "["..p.Prefix.Value.."]"..Name end
for _,v in pairs(game.Players:GetPlayers()) do
if not v:WaitForChild("Muted"):FindFirstChild(p.Name) then
MessageEvent:FireClient(v,Name..": "..Message:sub(1,50))
end
end
end
local function SPM(p,m)
MessageEvent:FireClient(p,"SERVER: "..m)
end
local function SM(m)
MessageEvent:FireAllClients("SERVER: "..m)
end
local function RAW(m)
MessageEvent:FireAllClients(m)
end
local function PRAW(p,m)
MessageEvent:FireClient(p,m)
end
local function Whisper(p,v,m)
local Name = p.Name
local Message = game.Chat:FilterStringForBroadcast(m,p)
local Nickname = p.FindFirstChild("Nickname") if Nickname then Name = p.Nickname.Value end
local Prefix = p:FindFirstChild("Prefix") if Prefix then Name = "["..p.Prefix.Value.."]"..Name end
if v:WaitForChild("Muted"):FindFirstChild(p.Name) then
PRAW(p,v.Name.." has muted you!")
else
PRAW(p, "Message Sent To "..v.Name)
PRAW(v,"From "..Name..": "..Message:sub(1,40))
end
end
MessageEvent.OnServerEvent:Connect(function(p,m)
if m:sub(1,6):lower() == "/mute " then
m=m:sub(7)
elseif m:sub(1,8):lower() == "unmute " then
m=m:sub(9)
elseif m:sub(1,3):lower() == "/w" then
m=m:sub(4)
elseif m:sub(1,1) == APrefix and isAdmin(p) then
m=m:sub(2)
else
Chat(p,m)
end
end)
game.Players.PlayerAdded:Connect(function(p)
local mutedfolder = Instance.new("Folder",p)
mutedfolder.Name = "Muted"
end)
Which appears to have no errors at all and is a normal Script
