Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a chat-scripting script?

Asked by
Minifig77 190
10 years ago

Recently, Kohl's admin commands' :s (scripting) command stopped working, meaning that I can no longer script from the chat, which was really nice. So, I'm trying to make a script of my own that will enable me to script from the chat.

I discovered that loadstring() can be used to run strings as scripts. I tried that, and nothing happened. Here's the code I've tried:

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        print("chatted")
        if string.sub(msg, 1, 2) == "s " then
            print("o:")
            pcall(function()
                loadstring(string.sub(msg, 3,string.len(msg)))()        
            end)
        end
    end)

end)

The script, in a nutshell, is supposed to check if the player put "s" in front of their message, signifying that it should be run as a script. Then, it should take the message after that and run it as a script.

Whenever I test the thing out, by chatting "s game.Workspace.Minifig77.Parent = game" it prints "chatted" and "o:", meaning that it detected that I want to script it. But, nothing happens. Why is this script not working?

1 answer

Log in to vote
0
Answered by 10 years ago

You probably just forgot to turn on your LoadStringEnabled which is a property of workspace.

Ad

Answer this question