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

msg = object, expected string?

Asked by 7 years ago
Edited 7 years ago
--Server Script
--\\ Services
local ReplicatedStorage = game:GetService'ReplicatedStorage'
--\\ Nicknames
local Event = ReplicatedStorage.ChatEvent
--\\ Main Code
Event.OnServerEvent:connect(function(ply,msg)
    Event:FireAllClients(ply,msg)
end)
--Client Script
--\\ Services
local ReplicatedStorage = game:GetService'ReplicatedStorage'
--\\Nicknames and Tables
local ply = script.Parent.Parent or game.Players.LocalPlayer
local Event = ReplicatedStorage.ChatEvent
local Admins = {'Vingam_Securis', 'Player1'}
--\\FireServerFunction
ply.Chatted:connect(function(msg)
    if msg ~= '' then
        Event:FireServer(ply,msg)
    elseif msg == '' then
        return
    end
end)
Event.OnClientEvent:connect(function(ply,msg)
    for i,v in pairs(Admins) do
        if ply.Name == v then
            print(ply.Name.. ' is an Admin.')
            local MO = script.Message_Owner:Clone()
            MO.Parent = ply.PlayerGui.ChatGui.Frame
            MO.Text = ply.Name..'~A~: '
            local MSG = script.Message:Clone()
            MSG.Parent = ply.PlayerGui.ChatGui.Frame
            MSG.Text = msg
        elseif ply.Name ~= v then
            print(ply.Name.. ' is not an Admin.')
        end
    end
end)

Players.Player1.PlayerScripts.ChattedScript:24: bad argument #3 to 'Text' (string expected, got Object)

1 answer

Log in to vote
1
Answered by 7 years ago

on line 11 of the Local Script, don't send the player.

You don't need to send the player manually because it will do it for you.

Local Script,

--Client Script
--\\ Services
local ReplicatedStorage = game:GetService'ReplicatedStorage'
--\\Nicknames and Tables
local ply = script.Parent.Parent or game.Players.LocalPlayer
local Event = ReplicatedStorage.ChatEvent
local Admins = {'Vingam_Securis', 'Player1'}
--\\FireServerFunction
ply.Chatted:connect(function(msg)
    if msg ~= '' then
        Event:FireServer(msg)-- Removed Player
    elseif msg == '' then
        return
    end
end)
Event.OnClientEvent:connect(function(ply,msg)
    for i,v in pairs(Admins) do
        if ply.Name == v then
            print(ply.Name.. ' is an Admin.')
            local MO = script.Message_Owner:Clone()
            MO.Parent = ply.PlayerGui.ChatGui.Frame
            MO.Text = ply.Name..'~A~: '
            local MSG = script.Message:Clone()
            MSG.Parent = ply.PlayerGui.ChatGui.Frame
            MSG.Text = msg
        elseif ply.Name ~= v then
            print(ply.Name.. ' is not an Admin.')
        end
    end
end)

Good Luck!

Ad

Answer this question