Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you add a localscript as a command?

I have a local script that works on a player, and I want it to activate on the player who types in the command ":goku me". Yes, this is the goku localscript. Answers are appreciated! Thanks!! P.S Filtering is enabled, and this will work only for certain players.

Attempt:

game.Players.PlayerAdded:connect(function(player)
    if player.Name == "MrNicNac" then
        player.Chatted:connect(function(msg)
 msg = :goku me
--not sure how to activate the localscript here
        end)
    end
end)

Thanks for replying!

1 answer

  1. You need to catch the command inside of chat. have you forked all/part of chat? I think there's a spot you can add hooks to messages and check if they match your text.

  2. I assume for this you will need the data on the server. So you'll need to have a way to communicate it to the local script, too. To get data back and forth you'll need remote events or remote functions: http://wiki.roblox.com/index.php?title=Remote_Events_and_Functions

Also, in terms of organization rather than setting up the username check during the playeradded, you can think of it like this:

  1. when the game starts monitor chats
  2. every time a chat comes in check the content & the sender
  3. if they match what you want, send information around to where it's needed.

3 comments

0

Sorry, but im really new and I dont know how to do any of that

0

Could you please show me steps how to do it?

0

Hey, I think a good plan would be to start with basic stuff that happens on the server. Make a modulescript which does things, etc, and gradually figure out the connection between local & server. That interaction is one of the hardest things to actually understand so it's not good for starting out.

This discussion is preserved as it was. New answers, comments, and votes are closed.