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

How do you add a localscript as a command?

Asked by 6 years ago

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

Log in to vote
0
Answered by 6 years ago
  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.
0
Sorry, but im really new and I dont know how to do any of that BADABOO2016 3 — 6y
0
Could you please show me steps how to do it? BADABOO2016 3 — 6y
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. Brouhahaha 27 — 6y
Ad

Answer this question