I am trying to add a player to a chat channel if they have a tool equipped, so for i have the following script. There is already a chat channel created and i can join it manually by typing /j Radio in the main chat window. When i equip the tool the script just prints equipped in the output window.
local ServerScriptService = game:GetService("ServerScriptService")
local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local Tool = script.Parent
function Equip()
print("equipped")
ChatService.SpeakerAdded:Connect(function(PlayerName)
print(PlayerName)
local Player = game.Players:FindFirstChild(PlayerName)
if Player and Player:GetRankInGroup(8370936) >= 190 then
print("Join the channel!")
local Speaker = ChatService:GetSpeaker(PlayerName)
Speaker:JoinChannel("Radio")
end
end)
end
function Unequip(mouse)
print(" not equipped")
end
Tool.Equipped:connect(Equip)
Tool.Unequipped:connect(Unequip)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.