What solutions have you tried so far? I don’t really use chat tags a lot so I don’t know how to fix this issue.
Script: StarterGui > ChatTagGui > Main > Tags > EggHunt2022 > Tag
script.Parent.Equip.MouseButton1Click:Connect(function(player)
local EggHunt_2022 = {
{
TagText = "🐰 EGG HUNT 2022",
TagColor = Color3.fromRGB(255, 170, 255)
}
}
local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService)
local speaker = nil
while speaker == nil do
speaker = ChatService:GetSpeaker(player.Name)
if speaker ~= nil then break end
wait(0.01)
end
if script.Equiped.Value == true then
local retags = {}
speaker:SetExtraData("Tags",retags)
else
speaker:SetExtraData("Tags",EggHunt_2022)
end
end)
You’re using a server script for this; you should use a local script as it is being run from the client (startergui).
Instead of “player.Name” (gui.MouseButton1Click does not return any arguments), you will have to get the player’s name with the path “game.Players.LocalPlayer.Name”
Also: This line, line 12,
is redundant as you are checking the same condition for the while loop.
This is what I currently have in my Main LocalScript
local player = game.Players.LocalPlayer
local BadgeService = game:GetService("BadgeService")
local BadgeId = 2125968751
script.Parent.Equip.MouseButton1Click:Connect(function()
local EggHunt_2022 = {
{
TagText = "🐰 EGG HUNT 2022",
TagColor = Color3.fromRGB(255, 170, 255)
}
}
local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService)
local speaker = nil
while speaker == nil do
speaker = ChatService:GetSpeaker(player.Name)
--if speaker ~= nil then break end
wait(0.01)
end
if script.Equiped.Value == true then
script.Equiped.Value = false
script.Parent.Equip.Text = "Equip"
script.Parent.Parent.Parent.Max.Value = false
---------------------------------
local retags = {}
speaker:SetExtraData("Tags",retags)
print("✅ | Unequiped")
else
if script.Parent.Parent.Parent.Max.Value == false then
script.Equiped.Value = true
script.Parent.Equip.Text = "Unequip"
script.Parent.Parent.Parent.Max.Value = true
---------------------------------
speaker:SetExtraData("Tags",EggHunt_2022)
print("✅ | Equiped")
end
end
end)
while wait(1) do
if BadgeService:UserHasBadge(player.UserId, BadgeId) then
script.Parent.Visible = true
else
script.Parent.Visible = false
end
end
Change script to local script and then put this code
script.Parent.Equip.MouseButton1Click:Connect(function()
local EggHunt_2022 = {
{
TagText = "🐰 EGG HUNT 2022",
TagColor = Color3.fromRGB(255, 170, 255)
}
}
local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService)
local speaker = nil
while speaker == nil do
speaker = ChatService:GetSpeaker(game.Players.LocalPlayer.Name)
if speaker ~= nil then break end
wait(0.01)
end
if script.Equiped.Value == true then
local retags = {}
speaker:SetExtraData("Tags",retags)
else
speaker:SetExtraData("Tags",EggHunt_2022)
end
end)
when player clicks the button by using local script , FireServer by using RemoteEvent. Then you put the chat codes stuffs inside server script. (that aerver script must be inside server script service.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EggHunt2022TAG = ReplicatedStorage:WaitForChild("EggHunt2022TAG")
local function EggHunt2022(player, Equiped)
print(player.Name .. " fired remote event (EggHunt2022TAG)")
local EggHunt_2022 = {
{
TagText = "🐰 EGG HUNT 2022",
TagColor = Color3.fromRGB(255, 170, 255)
}
}
local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService)
local speaker = nil
while speaker == nil do
speaker = ChatService:GetSpeaker(player.Name)
if speaker ~= nil then break end
wait(0.01)
end
if Equiped == true then
local retags = {}
speaker:SetExtraData("Tags",retags)
else
speaker:SetExtraData("Tags",EggHunt_2022)
end
end
EggHunt2022TAG.OnServerEvent:Connect(EggHunt2022)
LocalScript: StarterGui
local player = game.Players.LocalPlayer
local BadgeService = game:GetService("BadgeService")
local BadgeId = 2125968751
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("EggHunt2022TAG")
script.Parent.Equip.MouseButton1Click:Connect(function()
if script.Equiped.Value == true then
script.Equiped.Value = false
script.Parent.Equip.Text = "Equip"
script.Parent.Parent.Parent.Max.Value = false
---------------------------------
remoteEvent:FireServer(script.Equiped.Value)
print("✅ | Unequiped")
else
if script.Parent.Parent.Parent.Max.Value == false then
script.Equiped.Value = true
script.Parent.Equip.Text = "Unequip"
script.Parent.Parent.Parent.Max.Value = true
---------------------------------
remoteEvent:FireServer(script.Equiped.Value)
print("✅ | Equiped")
end
end
end)
while wait(1) do
if BadgeService:UserHasBadge(player.UserId, BadgeId) then
script.Parent.Visible = true
else
script.Parent.Visible = false
end
end
Everything works but it does not give the tag and there are no errors in the console…