His script reads the MembershipType
property of the Player
Instance that’s returned by Players.PlayerAdded
and compares it to an Enum
, so it will work without neither a Name nor a UserId.
Yeah, but I’m certain he followed it from a tutorial, so I don’t know if we can still help him here.
EDIT: He’s offline.
If he actually has the knowledge of the chat systems, then we can. Otherwise, we’ll just to have to leave the work to a professional.
Yeah, that’s likely a fact. Unless someone entirely rewrote his script, I doubt he’d make it past his current point.
I’ll try to explain better look at this script, is a script where ChatTag (Group Role), but as I want to identify the PREMIUM I wanted to try to make one but without putting user by user
The premium for each user so that when he enters and speaks through the chat he leaves {PREMIUM}
Could you help me to complement it?
I want that when a person who has the Premium, and speaks by the chat appears next to his name the PREMIUM
And in fact, the if
statement for MembershipType
was correct. I’ve only corrected your missing comma in the tags table.
On a side note, the script you’ve just provided doesn’t use tables correctly (Line 7:33-50
: {"verito728","PIRULYN1527"}
, not {"verito728"};{"PIRULYN1527"}
).
I see your error! Sorry this is a little late, but after TagText = "Premium"
, put a semicolon ( ; ) or a comma ( , ).
But for example if more people who have the Premium appear, they will not be tagged with the PREMIUM in the chat
What can I do? i really the need
The script will run for every player if you write it correctly, but what matters here is how you’re getting the Player
Instance:
currently, you’re retrieving it via Players.PlayerAdded
, which is technically not wrong but does not allow you to edit the behavior of the chat.
What you’re looking for is ChatService
, which is a module that is parented under ChatServiceRunner
(a child of ServerScriptService
) at runtime.
Example Script
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local ChatService = require(ServerScriptService:WaitForChild("ChatServiceRunner").ChatService)
ChatService.SpeakerAdded:Connect(function(playerName)
local speaker = ChatService:GetSpeaker(playerName)
local Player = Players[playerName]
if Player.MembershipType == Enum.MembershipType.Premium then
speaker:SetExtraData("Tags", {{TagText = "PREMIUM", TagColor = Color3.fromRGB(170, 0, 255)}})
end
end)
Your script is only partially correct, because:
- It does not actually reference the
ChatService
module anywhere, but indexes it at line5
; - It uses both
Players.PlayerAdded
andChatService.SpeakerAdded
, while the two of them return different values and different data types (respectivelyInstance
andstring
), meaning that the Player returned by the first event would differ from the one returned by the second (especially since the latter is only astring
representing the name of the player) and they would not be comparable; -
ChatService.SpeakerAdded
is inside ofPlayers.PlayerAdded
(aka; “for every player that joins, start listening for new speakers”, which would pick up other players as speakers while inside of a player-specific function, rendering it useless);
Reference:
For future posts, please make sure you know what you’re doing before jumping into complicated topics. Apologize my poor writing and explanation, it’s 2AM.
If this solves your problem, please mark it as a solution.
Wow thank you very much. You were a good person and very well educated, thank you very much for that great explanation