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

Im Trying To Make a Custom Chat And Trying To Use a RemoteFunction But It Keeps Giving Me An Error?

Asked by 4 years ago

Hi There, So Basiclly I Want To Make A Custom Chat That Works And Everything Is In One Gui And So I Tried Using A RemoteFunction But I Keep Getting This Error bad argument #1 (string expected, got Object) (Line 6) Here Is The LocalScript:

local input = script.Parent:WaitForChild("ChatBox")

input.FocusLost:Connect(function(enterPressed)
    if enterPressed == true then
        if string.len(input.Text) > 0 then
            script.Parent.Parent.Parent.ReF:InvokeServer(input.Text)
            input.Text = ''
        end
    end
end)

And Here Is The Normal Script:

local send = game:GetService("MessagingService")
local chatted = 'ChatConnected'


script.Parent.Parent.Parent.ReF.OnServerInvoke = function(input)
    if input == string.len(input) > 0 then
        send:PublishAsync(chatted,'{'.. script.Parent.Parent.Parent.Parent.Parent.Name.. '} '.. input)
    end
end

And Just Incase Here Is The Chat Text Script And GetFocus Script I Have Made:

ChatText (Script)

local Get = game:GetService("MessagingService")
local chatted = 'ChatConnected'

Get:SubscribeAsync(chatted,function(msg)
    script.Parent.Chat8.Text = script.Parent.Chat7.Text
    script.Parent.Chat7.Text = script.Parent.Chat6.Text
    script.Parent.Chat6.Text = script.Parent.Chat5.Text
    script.Parent.Chat5.Text = script.Parent.Chat4.Text
    script.Parent.Chat4.Text = script.Parent.Chat3.Text
    script.Parent.Chat3.Text = script.Parent.Chat2.Text
    script.Parent.Chat2.Text = script.Parent.Chat1.Text
    script.Parent.Chat1.Text = msg.Data
end)

GetFocus (LocalScript)

local uis = game:GetService("UserInputService")
local chatBox = script.Parent:WaitForChild("ChatBox")

uis.InputBegan:Connect(function(key, gameProcessed)
    if key.KeyCode == Enum.KeyCode.Slash and not gameProcessed then
        chatBox:CaptureFocus()
        wait()
        chatBox.Text = ''
    end
end)

Please Help If You Can Since This Is My First Time Using A RemoteFunction. Thank You!

0
Do you have a string value JesseSong 3916 — 4y
0
yh mahid786 41 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Perhaps you have a child of input (ChatBox) called text? If so, try renaming it to something else. Also, add an extra parameter to script.Parent.Parent.Parent.ReF.OnServerInvoke = function(input) like this:

script.Parent.Parent.Parent.ReF.OnServerInvoke = function(player, input)

The parameter player is automatically added.

0
nope i get a different error this time (attempt to compare number and boolean)(Line 6) mahid786 41 — 4y
0
oh youtubemasterWOW 2741 — 4y
Ad

Answer this question