Though these scripts are super long, I'll cut them and explain the problem. I have a localscript in my AdminGui that basically detects mousebutton clicks for buttons, and one is a send message to player button.
Message.MouseButton1Click:Connect(function()
if Target then
game.ReplicatedStorage.AdminEvent:FireServer("SendMessage", Target, minput)
end
end)
Message is a TextButton, Target is the player inputted in a textbox. minput is the Text in a TextBox (the message we want to send to the player). It fires a remotevent in ReplicatedStorage. I then have a long script in ServerScriptService which I'll also cut.
game.ReplicatedStorage.AdminEvent.OnServerEvent:Connect(function(Player, AdminAction, Target, reason)
if ParseAdmin(Player) then
if ParseAdmin(Target) then
game.ReplicatedStorage.AdminEvent:FireClient(Player, "ChatMessage", {Text = "You cannot moderate other moderators.", Color = Color3.fromRGB(226, 36, 26)})
return
end
if AdminAction == "Kick" then
Target:Kick("You have been kicked | Reason: "..reason)
elseif AdminAction == "SendMessage" then
local function message(minput)
game.ReplicatedStorage.AdminEvent:FireClient(Target, "ChatMessage", {Text = "From administrator: "..message, Color = Color3.fromRGB(226, 36, 26)})
end
elseif AdminAction == "Warn" then
game.ReplicatedStorage.AdminEvent:FireClient(Target, "ChatMessage", {Text = WarningText, Color = Color3.fromRGB(226, 36, 26)})
elseif AdminAction == "PermMute" then
Target.PlayerGui.Chat.Frame:Destroy()
elseif AdminAction == "DataReset" then
Target:WaitForChild("leaderstats").Quacks.Value = 0
Target:WaitForChild("leaderstats").Trust.Value = 0
elseif AdminAction == "ServerBan" then
Target:Kick("You have been banned from this server | Reason: "..reason)
for _, Object in pairs(script.ServerBannedPlayers:GetChildren()) do
if Object.Value == Target.Name then
return
end
end
local ServerBanValue = Instance.new("StringValue")
ServerBanValue.Name = "ServerBannedUserName"
ServerBanValue.Value = Target.Name
ServerBanValue.Parent = script.ServerBannedPlayers
elseif AdminAction == "GlobalBan" then
Target:Kick("You have been banned | Reason: "..reason)
local success, Banned = pcall(function()
return BanList:SetAsync(Target.UserId, true)
end)
if success then
game.ReplicatedStorage.AdminEvent:FireClient(Player, "ChatMessage", {Text = Target.Name.." has been globalbanned.", Color = Color3.fromRGB(226, 36, 26)})
else
game.ReplicatedStorage.AdminEvent:FireClient(Player, "ChatMessage", {Text = "Unbanning operation failed.", Color = Color3.fromRGB(226, 36, 26)})
end
end
end
end)
For now, we're focusing on the send message part:
elseif AdminAction == "SendMessage" then
local function message(minput)
game.ReplicatedStorage.AdminEvent:FireClient(Target, "ChatMessage", {Text = "From administrator: "..message, Color = Color3.fromRGB(226, 36, 26)})
end
If the clicked button is "Sendmessage" as defined by the functopm then fire to the Target (client) a chat message of whatever was put in that TextBox (minput). This, however, does not work. There are no errors in output. What's wrong with the script?
