So I am trying to create a PM system were when a admin runs the comman !pm [Username] [Message] it sends a user a message. I am not sure on how I can do this were a UI pops up with the message then they can send a reply. If anyone has any idea of how I could do this could you tell me thanks
The default ROBLOX chat already has private messages; you can click someone’s name to start messaging them regardless of whether you are an admin or not. The chat script can be configured to add channels for private messages, too. I don’t remember how that is done, or how you would message someone without clicking their name.
But as for making an actual PM GUI, here’s a top-level description of how it would work.
The admin messages the user. This is either with a command, or with a GUI on the admin’s screen.
The server receives an event (a remote event, client to server) that the admin PMed somebody. A script handles the event and fires another event for the target player only that they were PMed by somebody (the admin) with a message.
The player receives an event (server to client) that they were PMed with a message. If there was no PMing GUI visible on the screen, it is made visible. The message is put into the GUI. The GUI has a replying textbox. When the player sends a reply, it fires the exact same event the admin did when sending a message, but this time targets the admin. The server receives that event and passes it on to the admin, who also gets the reply GUI.
This is because MouseButton1Click doesn’t actually give any parameters. Player is nil and will never not be nil.
The serverscript is actually getting player-who-fired-remote, nil, message. You are printing nil because nil is Player is nil.
-- Events || Services --
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = ReplicatedStorage:WaitForChild("PM") --Using a WaitForChild("") is a must for me when getting an object and will wait until the game loads it so no error will happen.
-- Player with permission to use PM (UserID)
local Perms = {1, 1471902232} -- 1471902232 (This is your UserId)
-- Permission to use PM Function --
local function getPermission(getPlayer)
for _, playerUserId in pairs(Perms) do
if getPlayer.UserId == playerUserId then
return true
else
return false
end
end
end
--Player Stuff--
local Players = game:GetService("Players")
local LocalPlayer = Players.Localplayer
local Submit = script.Parent:WaitForChild("Submit")
local TextSubmit = script.Parent:WaitForChild("TextSubmit")
Submit.MouseButton1Click:Connect(function()
print("Clicked!")
local TextData = TextSubmit.Text
print(TextData)
local IdentifyMe = getPermission(LocalPlayer) -- Run the function
if IdentifyMe == true then
Remote:FireServer(TextData)
else
print(LocalPlayer.Name.." is trying to use the PermsPM without permission")
end
end)
Server Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = ReplicatedStorage:WaitForChild("PM")
Remote.OnServerEvent:Connect(function(Sender, DataText)
print("Remote Called!")
print(DataText)
end)
P.S:
I haven’t tested this on the Studio so if there’s an error im sorry for that. and let me know so we can fix it.
Try changing LocalPlayer = Players.Localplayer to LocalPlayer = Players.LocalPlayer. If it still doesn’t work at that point, can you check to see if the remote event is being fired from the client?