So I have a simple script that changes the FOV of the player using a simple property change.
workspace.Camera.FieldOfView = ""
But, I would prefer to do this through chat.
Ex. "fov 90" or "fov 100" etc etc I've researched some admin command type things but nothing really fits my needs. If you could contribute anything that would help! Thank you.
Hey!
Admin command systems are pretty easy to make. The only real "challenging" part (for some people) is the string manipulation. While it isn't difficult, it's just hard for some to wrap their heads around. Once you have your head wrapped around it, it becomes quite easy and you can make your argument handler as advanced as you really want it to be. For example, if you wanted, you could make it so that you predefine your arguments and automatically parse them to a player, string, int, etc... It really just depends on your programming knowledge and use case. Below is an example from the command table in a command handler I made a few months ago.
Lucky for you though, I actually helped somebody else out with getting started on their own little admin command system a few days ago and quickly wrote up a VERY simple framework to start working off of. Mind, this is a super simple system and I don't really recommend it for large scale use due to its simplicity.
local prefix = "!" local Commands = { ["fov"] = function(args) workspace.CurrentCamera.FieldOfView = tonumber(args[1]) end } game.Players.PlayerAdded:Connect (function(plr) plr.Chatted:Connect (function(msg) local args = string.split(msg, " ") -- this will separate the string into an array ("hey there" -> {"hey", "there"}) local cmd = args[1] -- first argument is going to be the commnad if cmd:sub(1,#prefix) == prefix then -- check if the prefix is at the start of the command cmd = cmd:sub(#prefix + 1, #cmd) -- remove the prefix from the command to make checks easier if Commands[cmd:lower()] then -- see if the command is present in the command table table.remove(args, 1) -- remove the first argument (command) because its useless now Commands[cmd:lower()](args) -- find the command in the commands table and call the function with arguments end end end) end)
I hope this helped you out a bunch and if this did help you, please remember to upvote and accept the answer.