of     1   

Crimsonal
#183484143Saturday, February 13, 2016 4:48 AM GMT

Commands = {} function OnChatted(p,msg) for i,v in pairs(Commands) do print(v[1]:len()) if msg:sub(1, i:len()):lower() == v[1]:lower() then v[2](p, msg:sub(i:len()+2)) end end end function getplayer(me,name) for i,v in pairs(game.Players:GetPlayers()) do if v.Name:sub(1, name:len()):lower() == name:lower() then return v end end end function AddCommand(cmd,func) Commands[cmd] = {cmd,func} end AddCommand("ff", function(p, msg) ypcall(function() Instance.new("ForceField", getplayer(p, msg).Character) end) end) AddCommand("kill", function(p, msg) getplayer(p, msg).Character:BreakJoints() end) game.Players.PlayerAdded:connect(function(x) x.Chatted:connect(function(msg) OnChatted(x,msg) end) end) Better than that other way?
128Gigabytes
#183484247Saturday, February 13, 2016 4:51 AM GMT

https://www.youtube.com/watch?v=OvseAKgAIig
Crimsonal
#183484378Saturday, February 13, 2016 4:53 AM GMT

eh, i'm gonna stick with this way
chimmihc
#183485314Saturday, February 13, 2016 5:12 AM GMT

"efficient" Use # instead of the len function, it is much faster.
Crimsonal
#183486684Saturday, February 13, 2016 5:40 AM GMT

I like it the way it looks and using a # does not effect the speed of the code, it is fast already -_-
chimmihc
#183486946Saturday, February 13, 2016 5:45 AM GMT

"# does not effect the speed of the code" Yes, it does.
128Gigabytes
#183487267Saturday, February 13, 2016 5:52 AM GMT

--[[+ 1 to all results to avoid scientific notations.]] local input, returns, tick, total = ("_"):rep(1000000), {}, tick, 0 for x = 1, 7999, 1 do local start = tick() local _ = string.len(input) table.insert(returns, (tick() - start)) end for _, x in next, (returns) do total = (total + x) end print("string.len() fastest time + 1; " .. (math.min(unpack(returns)) + 1)) print("string.len() slowest time + 1; " .. (math.max(unpack(returns)) + 1)) print("string.len() average time + 1; " .. ((total / #returns) + 1)) print('') returns, total = {}, 0 for x = 1, 7999, 1 do local start = tick() local _ = input:len() table.insert(returns, (tick() - start)) end for _, x in next, (returns) do total = (total + x) end print("len() fastest time + 1; " .. (math.min(unpack(returns)) + 1)) print("len() slowest time + 1; " .. (math.max(unpack(returns)) + 1)) print("len() average time + 1; " .. ((total / #returns) + 1)) print() returns, total = {}, 0 for x = 1, 7999, 1 do local start = tick() local _ = #input table.insert(returns, (tick() - start)) end for _, x in next, (returns) do total = (total + x) end print("# fastest time + 1; " .. (math.min(unpack(returns)) + 1)) print("# slowest time + 1; " .. (math.max(unpack(returns)) + 1)) print("# average time + 1; " .. ((total / #returns) + 1)) --[[>string.len() fastest time + 1; 1 string.len() slowest time + 1; 1.0000791549683 string.len() average time + 1; 1.0000004096543 len() fastest time + 1; 1 len() slowest time + 1; 1.0000157356262 len() average time + 1; 1.0000003531123 # fastest time + 1; 1 # slowest time + 1; 1.000007390976 # average time + 1; 1.0000002318911, results will very.]]
Crimsonal
#183504535Saturday, February 13, 2016 2:55 PM GMT

I said before that it's already very fast. I don't need to change something just to get an extra millisecond. It's useless.
wonderful72pike
#183504705Saturday, February 13, 2016 2:58 PM GMT

Yes that's actually a really efficient way. Looping over a table, finding the command, and launching the function i s the best way you can be doing it (out of the very few ways this can even be done).
JarodOfOrbiter
#183508772Saturday, February 13, 2016 3:55 PM GMT

If you don't want your code to be efficient, why did you even ask? You're totally ignoring people who are suggesting ways to make it more efficient.
Crimsonal
#183518595Saturday, February 13, 2016 6:20 PM GMT

If I don't find efficient to me, then I don't like it Because a # over a len is useless
foreverpower
#183518898Saturday, February 13, 2016 6:24 PM GMT

Efficiency isn't about nitpicking code with a negligible impact on performance.
JarodOfOrbiter
#183519003Saturday, February 13, 2016 6:26 PM GMT

I know, but he said "Most efficient", and it is not. He says he doesn't really care about miniscule differences in efficiency though, in which case idk why he even asks since pretty much everything is unnoticeable.
JarodOfOrbiter
#183519215Saturday, February 13, 2016 6:30 PM GMT

Unless he only posted his script here to brag, but has such a huge ego that he can't stand his question being answered.
Crimsonal
#183519377Saturday, February 13, 2016 6:32 PM GMT

I just wanted to see if there was any better way because i've seen it before btw, you can stop bumping this because I'm just gonna stick to this way :D
foreverpower
#183519402Saturday, February 13, 2016 6:32 PM GMT

There are still other changes to the overall structure of the script that can have a noticeable impact on performance.
killerbot29003
#183520182Saturday, February 13, 2016 6:43 PM GMT

If you're gonna stick to your way, then why even posting this? This siggy is copyrighted ©
Crimsonal
#183522183Saturday, February 13, 2016 7:11 PM GMT

"btw, you can stop bumping"
128Gigabytes
#183530979Saturday, February 13, 2016 9:04 PM GMT

If to had to guess Jarod is right and he posted here to try and brag, Maybe he is hurt that the one I threw together for a video is the same concept as his.
Crimsonal
#183533587Saturday, February 13, 2016 9:42 PM GMT

Um no, you're wrong. You're all wrong. I have seen this method before and I've finally understood on how to use it. if you want to see the video I learn off here: https://www.youtube.com/watch?v=zK5AT4zXCOA I knew that was a good way, and I was just seeing if there was a better way. But all I got was just use a # instead of len()

    of     1