Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does my Custom Chat only work in studio?? HttpService is enabled

Asked by 7 years ago

I'm trying to make a custom chat and it seems to be successful but it only works in studio? Why? Here's what the setup looks like https://ibb.co/mYZ4i5

Here's the code for the "ChatServer" script

local RepStorage = game:GetService'ReplicatedStorage'

local ChatEvent  = RepStorage:WaitForChild'ChatRemote'

local HttpService = game:GetService("HttpService")

local function filterMessage(message)
        return HttpService:GetAsync("http://www.purgomalum.com/service/plain?text="..message, true)
end

ChatEvent.onServerEvent:connect(function(Client, Request, Value)
    Request:lower()
    if Request == "chat" then
        local filteredMessage = filterMessage(Value)
        ChatEvent:FireAllClients("chat",filteredMessage,Client.Name)
    end
end)

Here's the code for the "ChatClient" localscript

local RepStorage = game:GetService'ReplicatedStorage'
local Players    = game:GetService'Players'
local StarterGui = game:GetService'StarterGui'

local ChatEvent = RepStorage:WaitForChild'ChatRemote'

local Client = Players.LocalPlayer
local Mouse  = Client:GetMouse()

local Chatbar   = script.Parent
local ChatFrame = script.Parent.Parent.Frame

local Chats = {}

local function PushMessages(Size)
    for i,v in pairs(Chats)do
        v.Position = v.Position - UDim2.new(0,0,0,Size)
        if v.Position.Y.Offset < -ChatFrame.AbsoluteSize.Y then
            Chats[i] = nil
            v:Destroy()
        end
    end
end

local function CreateMessage(Message,Speaker)
    local Label = Instance.new'TextLabel'
    Label.BackgroundTransparency = 1
    Label.TextXAlignment         = 'Left'

    Label.TextColor3 = Color3.new(1,1,1)

    Label.Font     = "ArialBold"
    Label.FontSize = Enum.FontSize.Size18
    Label.Size     = UDim2.new(1,0,0,25)
    Label.Position = UDim2.new(0,0,1,-25)
    Label.Text = tostring(Speaker)..": "..Message
    PushMessages(Label.Size.Y.Offset)
    Chats[#Chats+1] = Label
    Label.Parent = ChatFrame
    Label.TextScaled = true
    Label.TextWrapped = true
end

Mouse.KeyDown:connect(function(Key)
    if Key:byte() == 47 then
        Chatbar:CaptureFocus()
    end
end)

Chatbar.FocusLost:connect(function(Enter)
    if Enter then
        if Chatbar.Text == '' then
            return
        end
        ChatEvent:FireServer("chat",Chatbar.Text)
        Chatbar.Text = ''
    end
end)

ChatEvent.OnClientEvent:connect(function(Request, Message, Speaker)
    Request = Request:lower()
    if Request == "chat" then
        CreateMessage(Message, Speaker)
    end
end)

StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)

0
Might I ask why you're not using the Roblox Built-In filtering API? Are you attempting to use the alternative service due to the current system going offline or producing false positives frequently? http://wiki.roblox.com/index.php?title=API:Class/Chat/FilterStringAsync M39a9am3R 3210 — 7y
0
You have to use ROBLOX's filter, not a third party one. User#10445 15 — 7y
0
Might you be able to walk us through the code, possibly place print statements at suspected areas where the code may be failing and gather data from the variables? This may help us focus on the areas we should be searching. M39a9am3R 3210 — 7y
0
Do you know how I could change this to work with Roblox's filter? greybird700 63 — 7y

Answer this question