Trying to make a chat command to get myself Wanted like GTA-V

Hey developers, Can you help me figure out how to make a chat command with the command being /Wanted? Basically i want the command to trigger this line of code:

local crime = require(game.ServerScriptService.Crime)

					crime.increaseWantedLevel(script.Parent.Parent,1)

There is a module script called Crime in serverscriptservice and the line of code above me is linked to it.

Here is now the full script:

function chat(msg, sender)

	local delimiter_point=msg:find("/", 1, true) --Find the delimiter in the string

	if delimiter_point then --Make sure it's actually there

		local command = msg:sub(1, delimiter_point-1)

		local arg = msg:sub(delimiter_point+1)

		--We have the command and argument. It's now time to start with the commands :D

		

		if command == "message" then

			local x = Instance.new("Message", workspace) --Create a message

			x.Text = arg --Set its text to the text after the delimiter

			game.Debris:AddItem(x, 5) --Remove the message after five seconds.

		elseif command == "Wanted" then

			if game.Players:findFirstChild(arg) then --See if player is in game

				local x = game.Players:findFirstChild(arg) -- Set a variable for the player found

				if x.Character then 
					
					local crime = require(game.ServerScriptService.Crime)

					crime.increaseWantedLevel(script.Parent.Parent,1)
					
					

				end

			end

		end

	end

end



game.Players.PlayerAdded:connect(function(plr)

	repeat wait() until plr.Character

	plr.Chatted:connect(function(msg)

		chat(msg, plr)

	end)

end)

It does not work and I got no errors at all?

1 Like

nevermind I found how to do it

1 Like