Let’s get right to it.
I have a chat tag script which looks like this:
local players = game:GetService("Players")
local chatService = require(game.ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local tags = {
[-1] = {TagText = "OWNER", TagColor = Color3.fromRGB(15, 255, 219)},
}
chatService.SpeakerAdded:Connect(function(playerName)
local speaker = chatService:GetSpeaker(playerName)
local player = game.Players[playerName]
if tags[player.UserId] then
speaker:SetExtraData("Tags", {tags[player.UserId]})
end
end)
How do I make it so whenever a player has a value of 1
in their Player.leaderstats.Bread
they will get a special chat tag?
You already hae the player instance, you can wait for their leaderstats to exist and check their bread value. This will only work when their speaker is added so you’d have to do code related to this for when the value changes to the bread value you want via a Changed
event. You’d have to make a table to contain all their chat tags since you’ll have multiple tags from 2 different if statements, you’d have to do something like this
local players = game:GetService("Players")
local chatService = require(game.ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local tags = {
[-1] = {TagText = "OWNER", TagColor = Color3.fromRGB(15, 255, 219)},
}
chatService.SpeakerAdded:Connect(function(playerName)
local speaker = chatService:GetSpeaker(playerName)
local player = game.Players[playerName]
local leaderstats = player:WaitForChild("leaderstats")
local tagslist = {}
if tags[player.UserId] then
table.insert(tagslist, tags[player.UserId])
end
if leaderstats.Bread.Value == 1 then
table.insert(tagslist, {TagText = "BREAD", TagColor = Color3.fromRGB(255,255,255)}
end
speaker:SetExtraData("Tags", tagslist)
end)
1 Like
Thank you for your help, this worked!
1 Like
Anytime! if you have anymore issues don’t be afraid to make another post!!
1 Like