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

Unable to cast value to Object?

Asked by 7 years ago

Hi, so i'm trying to make a custom chat gui feature and so I need to filter my chat. But when I try to do it I get this error: Unable to cast value to Object.

Filter Line:

local filteredText = game.Chat:FilterStringForBroadcast(Message, Speaker)

Where Message is coming from:

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

Thanks :)

0
I notice you used the code from my old chat system video :D. Most of the content in that video is very out of date, so I would recommend changing a lot. ScriptGuider 5640 — 7y
0
Oh yeah! Thanks a lot for the video it helps me a lot for custom chat and would you know how to fix it since you made it? Its fine if you dont KingStared 3 — 7y
0
What the CreateMessage() function? MinePlayersPE1 33 — 7y
0
I posted the CreateMessage() function KingStared 3 — 7y

1 answer

Log in to vote
-1
Answered by 7 years ago

There you go MinePlayersPE1

local function CreateMessage(Message, Speaker)
    local filteredText = game.Chat:FilterStringForBroadcast(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 = "Size18"
    Label.Size = UDim2.new(1,0,0,25)
    Label.Position = UDim2.new(0,0,1,-25)
    if game.CreatorId == Speaker.userId then
        Label.Text = "[OWNER]"..tostring(Speaker)..": "..filteredText
        Label.Label.TextColor3 = Color3.new(255/255, 147/255, 23/255)
    else
        Label.Text = tostring(Speaker)..": "..filteredText
    end
    PushMessages(Label.Size.Y.Offset)
    Chats[#Chats+1] = Label
    Label.Parent = ChatFrame
end
Ad

Answer this question