TextChatCommand doesn't run?

I’m working on a votekick command (disaster), and uh, the entire code doesn’t run for some reason

local rStorage = game:GetService("ReplicatedStorage")
local tChatService = game:GetService("TextChatService")

-- Folders;
local events = rStorage:WaitForChild("Events")
local toClient = events:WaitForChild("ToClient")
local votekickUI = toClient:WaitForChild("VotekickUI")

-- Events;
local failedVotekickMessage = votekickUI.FailedVotekickMessage


local votekickCommand = tChatService:WaitForChild("Votekick")
local players = game:GetService("Players")

-- Get players;
local function GetPlayers()
	local playerList = {}
	
	for _,plr in ipairs(players:GetPlayers()) do
		if not table.find(playerList, plr.Name) then
			table.insert(playerList, plr.Name)
		end
	end
	
	return playerList
end

-- Once command gets triggered;
local function OnCommandTriggered(origin: Player, unfilteredText: string)
	local playerList = GetPlayers()
	
	local args = string.split(unfilteredText, " ")
	local playerName = args[2]
		
	if playerName and table.find(playerList, playerName) then
		
	else
		print("Failed votekick, the provided player does not exist, or player wasn't provided at all.")
		
		local message = "The player you've provided does not exist or you didn't provide a player at all. Please double check if the player exists and the player's username."		
		failedVotekickMessage:FireClient(origin, message)
	end
end

votekickCommand.Triggered:Connect(OnCommandTriggered)

and this is (dora) the explorer:
image

1 Like

What exactly doesn’t work. Is the function not firing? Put some print statements and see what happens when the function is triggered.

no like, legit the entire code doesn’t run

image

I don’t think you need to put it in the textchatservice. I think you need to put it in server script service. And try something like this.

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		if msg == "/votekick" and player then
		print("Voting Started")
		end
	end)
end)
1 Like

ohhhhh

it DOES have to be in serverscriptservice

OOPS

1 Like

Im glad you got that sorted out.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.