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

GetSpeaker with player.Name outputting (a nil value)?

Asked by 5 years ago

This inputs - ServerScriptService.TagsConfigurer:6: attempt to index local 'Speaker' (a nil value)

local ChatService = require(script.Parent:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))

game:GetService("Players").PlayerAdded:Connect(function(player)
    local Speaker = ChatService:GetSpeaker(player.Name)
    Speaker:SetExtraData("Tags", {{TagText = "["..player:GetRoleInGroup(5042036).."]", TagColor = player.TeamColor.Color}})
end)

1 answer

Log in to vote
0
Answered by 5 years ago

Try this:

local ChatService = require(script.Parent:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local Players = game:GetService('Players')

ChatService.SpeakerAdded:Connect(function(PlayerName)
    local Speaker = ChatService:GetSpeaker(PlayerName)
    local player = Players[PlayerName]
    Speaker:SetExtraData("Tags", {{TagText = "["..player:GetRoleInGroup(5042036).."]", TagColor = player.TeamColor.Color}})
end)

Ad

Answer this question