A ServerScript will detect if RPName.TextLabel(called Name) matches player.Name.
If it matches it will add a Tag to the Chat.
If not, nothing will happen.
Code:
local ChatService = require(game:GetService(“ServerScriptService”):WaitForChild(“ChatServiceRunner”):WaitForChild(“ChatService”))
ChatService.SpeakerAdded:Connect(function(player)
local Speaker = ChatService:GetSpeaker(player)
local character = player.Character
local function xa()
while wait(1) do
if player.Name == character.Head.RPName:FindFirstChild(“Name”).Text then
print(1)
Speaker:SetExtraData(–[[someting]])
Speaker:SetExtraData(–[[someting]])
Speaker:SetExtraData(–[[someting]])
else
–
end
end
end
xa()
end)
What’s the problem?
For some reason I get the following error:
What am I doing wrong?
Note: for those who downloaded the file, the RPName does not exist in this place, as the problem is not with its location but with the location of the Head.
putting the new line above, now nothing will be read below line 6.
I was supposed to print “finish” but nothing happens.
It was also supposed to give an error that the RPName does not exist but nothing happens in the output either
SpeakerAdded returns the speakername (playername), not the player instance.
You can use Speaker:GetPlayer(), example:
local ChatService = require(ChatServiceModuleLocation)
local function SpeakerAdded
(SpeakerName)
local Speaker = ChatService:GetSpeaker(SpeakerName)
local Player = Speaker:GetPlayer()
if (Player)
then
local Character = Player.Character or Player.CharacterAdded:Wait()
local Head = Character.Head
-- Code.
end
end
local GetSpeakers = ChatService:GetSpeakerList()
for i = 1, (#GetSpeakers)
do
task.spawn(SpeakerAdded, GetSpeakers[i])
end
ChatService.SpeakerAdded:Connect(SpeakerAdded)