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

How do I get this message appear on one persons screen with a normal script?

Asked by 7 years ago

I am making a admin script and when someone says "cmds/" I want a message (A Normal message you know the :"Instance.new("Message") kind) that only shows on the player's screen. This is the code I have right know.

if message:sub(1,5) == "cmds/" then
            local message = Instance.new("Message", workspace)
            message.Text = "Commands: btools | kick/ | msg/ | setmessage/ | remove/ | music/ | end/ | pause/ | resume/ | volume/ | reset/ | shutdown/"
            wait(5)
            message:Destroy()
        end

2 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago
local plrs = game:GetService("Players"):GetChildren() --Get players

ChatEvent = function(sender) --sender is the person who sent the message
    sender.Chatted:Connect(function(msg) --msg is the msg itself (as a string)
        if string.lower(msg:sub(1,5)) == "cmds/" then
            local message = Instance.new("Message", sender:FindFirstChild("PlayerGui"))
            message.Text = "Commands: btools | kick/ | msg/ | setmessage/ | remove/ | music/ | end/ | pause/ | resume/ | volume/ | reset/ | shutdown/"
            wait(5)
            message:Destroy()
        end
    end)
end

for _,OldPlayer in pairs(plrs) do --you should keep this as you can then test in studio
    ChatEvent(OldPlayer)
end

game.Players.PlayerAdded:Connect(function(NewPlayer) --New player is the player that joined
    ChatEvent(NewPlayer)
end)

This would be a server script. It works, when I tested it. Hope this answers your question.

Ad
Log in to vote
-1
Answered by 7 years ago

There are many tutorial channels related to this topic like AlvinBlox and other channels

Answer this question