Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How do I make a system message that shows locally to a player (I.E "Hey Stea_my! You're an admin!")?

Asked by
Stea_my 19
14 days ago
Edited 14 days ago

I think this is just a newbie mistake but I'd like to make a message in the chat that only shows up for admins in their gui. It shows up for everyone and this is no desirable. This is probably a super newbie mistake but I haven't done this type of thing before, heres my code.

local eventyboys = game.ReplicatedStorage.Events
local gooey = game.StarterGui

eventyboys.Yes.OnClientEvent:connect(function(plr)
    gooey:SetCore("ChatMakeSystemMessage", {
        Text = "Hello, "..plr.Name.."! You are an Admin! Type ;cmds for commands.";
        Color = Color3.fromRGB(0, 16, 176);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
        })
end)

eventyboys.AskedForCmds.OnClientEvent:connect(function(plr)
        gooey:SetCore("ChatMakeSystemMessage", {
        Text = "Admin Commands List";
        Color = Color3.fromRGB(255, 0, 0);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
    })
    gooey:SetCore("ChatMakeSystemMessage", {
        Text = "---------------------";
        Color = Color3.fromRGB(0, 16, 176);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
    })
        gooey:SetCore("ChatMakeSystemMessage", {
        Text = ";cmds";
        Color = Color3.fromRGB(255, 0, 0);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
        })
                gooey:SetCore("ChatMakeSystemMessage", {
        Text = ";ff";
        Color = Color3.fromRGB(255, 0, 0);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
                })
                        gooey:SetCore("ChatMakeSystemMessage", {
        Text = ";rage";
        Color = Color3.fromRGB(255, 0, 0);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
                        })
                                gooey:SetCore("ChatMakeSystemMessage", {
        Text = ";dust";
        Color = Color3.fromRGB(255, 0, 0);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
                                })
                                                                gooey:SetCore("ChatMakeSystemMessage", {
        Text = ";lit";
        Color = Color3.fromRGB(255, 0, 0);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
                                                                })
gooey:SetCore("ChatMakeSystemMessage", {
        Text = ";nukeevent";
        Color = Color3.fromRGB(255, 0, 0);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
})
gooey:SetCore("ChatMakeSystemMessage", {
        Text = ";kick";
        Color = Color3.fromRGB(255, 0, 0);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
})
gooey:SetCore("ChatMakeSystemMessage", {
        Text = ";burntheashes";
        Color = Color3.fromRGB(255, 0, 0);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
})
gooey:SetCore("ChatMakeSystemMessage", {
        Text = "---------------------";
        Color = Color3.fromRGB(0, 16, 176);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
    })                                                              

end)

Heres also the way the Events fire, that might be the problem aswell.

game:GetService("Players").PlayerAdded:Connect(function(plr)
    for _,v in pairs(ADMANS) do
        if (v == plr.UserId) then
            eventyboys.Yes:FireClient(plr)
            plr.Chatted:Connect(function(msg)
                if (string.sub(msg,0,1) == ";") then
                    local args = Split(msg)
                    if (Commands[args[1]] ~= nil) then
                        Commands[args[1]](args,plr)
                    end
                end
            end)    
        end
    end
end)
0
why not just doing playeradded/characteradded event and then showing the message EternalScythe 157 — 14d
0
because the event has to check in another script, this is in starterplayerscripts. again, im a newbie at this type of scripting. Stea_my 19 — 14d
0
Use game.Players.LocalPlayer instead of "plr". As .OnClientEvent on line 4 doesn't return the player. Denny9876 1287 — 14d
0
Can you show me what you mean, Denny? Stea_my 19 — 14d
View all comments (16 more)
0
On line 6, replace "plr.Name" with "game.Players.LocalPlayer.Name". Denny9876 1287 — 14d
0
OHH you misunderstood me, I'm sorry, the script saying "Hello Stea_my!" works, its just showing for everybody and not the player who is admin, if you have any fixes for it please explain, thank you! Stea_my 19 — 14d
0
Oh, sorry about that. How are you firing the events? Are you using :FireAllClients()? Denny9876 1287 — 14d
0
Yes I am. Stea_my 19 — 14d
0
I have a list of admins that when I want to give them commands it fires an event called "Yes" using :FireAllClients(). Stea_my 19 — 14d
0
Well, it should be easy to figure out then. It's firing to ALL the clients/players, so everyone sees the message. Instead, do :FireClient(plr) to fire it to a specific player. "plr" has to be the player object, and note you don't get the player still on .OnClientEvent. Denny9876 1287 — 14d
0
I will try this, thank you! Stea_my 19 — 14d
0
No problem. Also, if the list are names, you can do something like game.Players:FindFirstChild(playernamehere) to get the player object. Denny9876 1287 — 14d
0
It seems to work for another client event I'm doing but on the join event when I fire the client event it doesn't do anything. Stea_my 19 — 14d
0
I have added the way the on joined event fires for "Yes", if you can tell me what went wrong that'd be great! Stea_my 19 — 14d
0
Hmm...okay. Are you using UserIds in the "ADMANS" list or names? Your script only works for UserIds. Also, which client event isn't working? I tested out your script and it seems to work for me, but I couldn't test the chatted event part. Denny9876 1287 — 14d
0
"ADMANS" is a UserId table, and the client event that is broken is "Yes", "AskedForCmds" works. Stea_my 19 — 14d
0
Strange. The "Yes" event works for me. On the local script, did you replace "plr.Name" with "game.Players.LocalPlayer.Name"? Denny9876 1287 — 14d
0
No, I didn't. Stea_my 19 — 14d
0
There is an error in the script that says "Failed to index local plr (a nil value)" Stea_my 19 — 14d
0
I did what you said with using localplayer, it worked! I believe my script is fully functional, thank you, I will test it with other players later. Stea_my 19 — 14d

1 answer

Log in to vote
0
Answered by 14 days ago
Edited 14 days ago

You used StarterGui rather than PlayerGui. try this instead!

local eventyboys = game.ReplicatedStorage.Events
local plr = game.Players.LocalPlayer
local gooey = plr.PlayerGui

eventyboys.Yes.OnClientEvent:connect(function(plr)
    gooey:SetCore("ChatMakeSystemMessage", {
        Text = "Hello, "..plr.Name.."! You are an Admin! Type ;cmds for commands.";
        Color = Color3.fromRGB(0, 16, 176);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
        })
end)

eventyboys.AskedForCmds.OnClientEvent:connect(function(plr)
        gooey:SetCore("ChatMakeSystemMessage", {
        Text = "Admin Commands List";
        Color = Color3.fromRGB(255, 0, 0);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
    })
    gooey:SetCore("ChatMakeSystemMessage", {
        Text = "---------------------";
        Color = Color3.fromRGB(0, 16, 176);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
    })
        gooey:SetCore("ChatMakeSystemMessage", {
        Text = ";cmds";
        Color = Color3.fromRGB(255, 0, 0);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
        })
                gooey:SetCore("ChatMakeSystemMessage", {
        Text = ";ff";
        Color = Color3.fromRGB(255, 0, 0);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
                })
                        gooey:SetCore("ChatMakeSystemMessage", {
        Text = ";rage";
        Color = Color3.fromRGB(255, 0, 0);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
                        })
                                gooey:SetCore("ChatMakeSystemMessage", {
        Text = ";dust";
        Color = Color3.fromRGB(255, 0, 0);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
                                })
                                                                gooey:SetCore("ChatMakeSystemMessage", {
        Text = ";lit";
        Color = Color3.fromRGB(255, 0, 0);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
                                                                })
gooey:SetCore("ChatMakeSystemMessage", {
        Text = ";nukeevent";
        Color = Color3.fromRGB(255, 0, 0);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
})
gooey:SetCore("ChatMakeSystemMessage", {
        Text = ";kick";
        Color = Color3.fromRGB(255, 0, 0);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
})
gooey:SetCore("ChatMakeSystemMessage", {
        Text = ";burntheashes";
        Color = Color3.fromRGB(255, 0, 0);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
})
gooey:SetCore("ChatMakeSystemMessage", {
        Text = "---------------------";
        Color = Color3.fromRGB(0, 16, 176);
        Font = Enum.Font.SourceSansBold;
        FontSize = Enum.FontSize.Size96;
    })                                                              

end)

Ad

Answer this question